ajuste función y(h) con 7 parámetros
Publicado por Aura (33 intervenciones) el 08/04/2014 13:17:10
Hola,
tengo dos columnas de datos (h,y) y quiero ajustarles una función, para ello me he basado en un ejemplo de internet en el que utilizaban la 'fminsearch' sin embargo debe haber algún fallo en mi código. Lo copio:
-----------------
function U=OF(C)
global h y
y2=C(1)*exp(-h./C(2))+C(3)*exp(-h./C(4))+C(5).*(exp(-C(6)/6.9^C(7))-exp(-C(6)./(log(h)).^C(7)));
U=norm(y-y2,1); %Manhattan norm of the difference
%C(4)>C(2)
-----------------
clear; clc; format compact; close all
global h y
Data = xlsread('Book1.xls');
h=Data(:,2);
y=Data(:,3);
figure
semilogx(h,y)
fx='OF';
C0=[0.05,20,0.035,3500,25,5,0.12];
options=optimset('MaxIter',1000,'TolX',1e-10,'Display','Iter');
[C,f,EF,out]=fminsearch(fx,C0,options);
y2=C(1)*exp(-h./C(2))+C(3)*exp(-h./C(4))+C(5).*(exp(-C(6)/6.9^C(7))-exp(-C(6)./(log(h)).^C(7)));
figure
semilogx(h,y,'-o',h,y2,'r-.^')
legend('data','fit')
ylabel('y')
xlabel('h')
axis([0 10000000 0 1]);
-----------------
¿Podríais ayudarme? :)
Aura.
tengo dos columnas de datos (h,y) y quiero ajustarles una función, para ello me he basado en un ejemplo de internet en el que utilizaban la 'fminsearch' sin embargo debe haber algún fallo en mi código. Lo copio:
-----------------
function U=OF(C)
global h y
y2=C(1)*exp(-h./C(2))+C(3)*exp(-h./C(4))+C(5).*(exp(-C(6)/6.9^C(7))-exp(-C(6)./(log(h)).^C(7)));
U=norm(y-y2,1); %Manhattan norm of the difference
%C(4)>C(2)
-----------------
clear; clc; format compact; close all
global h y
Data = xlsread('Book1.xls');
h=Data(:,2);
y=Data(:,3);
figure
semilogx(h,y)
fx='OF';
C0=[0.05,20,0.035,3500,25,5,0.12];
options=optimset('MaxIter',1000,'TolX',1e-10,'Display','Iter');
[C,f,EF,out]=fminsearch(fx,C0,options);
y2=C(1)*exp(-h./C(2))+C(3)*exp(-h./C(4))+C(5).*(exp(-C(6)/6.9^C(7))-exp(-C(6)./(log(h)).^C(7)));
figure
semilogx(h,y,'-o',h,y2,'r-.^')
legend('data','fit')
ylabel('y')
xlabel('h')
axis([0 10000000 0 1]);
-----------------
¿Podríais ayudarme? :)
Aura.
Valora esta pregunta


0