Hello all,
I'm pacticing 3-4 parametrs fitting for kinetic rate equations, started with a simple example and looked at lsqnonlin option.
I'm getting results that are fare from my initial set even for different initial guess.
Also checked the levenberg-marquardt option (It is unconstrained).
Please advise of more definitions for a better convergance.
Thank you,
YA
zzx % For cleaning = clc +clear all
n=50;
x = linspace(0.5,4.1,n);
y=linspace(0.5,4.1,n);
p0=[1.75 1.4 2.5 1.8];
z=zeros(n);
k=0;
w=[x,y];
for i = 1:n
for j=1:n
k=k+1;
z(i,j)=p0(1)*x(i)^p0(2)+(y(j)^p0(3))+p0(4);
t(k)=z(i,j);
end
end
nexttile
surf(x,y,z)
title('True plot')
t0=t;
t=t0+randn(size(t0))*0.1;
fun=@(p)p(1)*w(1)^p(2)+(w(2)^p(3))+p(4)-t;
p00=[1.8 1.1 2.1 1.3];
lb=[1 1 2 0];
ub=[4 5 5 2];
options = optimoptions('lsqnonlin','Display','iter');
p=lsqnonlin(fun,p00,lb,ub,options)
for i = 1:n
for j=1:n
k=k+1;
z1(i,j)=p(1)*x(i)^p(2)+(y(j)^p(3))+p(4);
t(k)=z(i,j);
end
end
nexttile
surf(x,y,z1)
title('Regression plot')
Best Answer