Hello all,
Actually, I am dealing with an issue that I can't get desirable results out of my curve-fitting problem. I used lsqcurvefit in the first place. Then, I added MultiStart to my code as well but my result didn't change. I don't know why MATLAB gives the unknown model coefficient the same value as I entered for MATLAB. I bring my code in the following along with the results. I would really appreciate it if you can help me fix this problem and get better results:
clcclear all;close all;%xdata
T = 294:0.1:361;T=T';%ydata
for i=1:size(T,1)f1(i)= 0.2099*exp(-((T(i)-340.2)/2.439).^2);endf1=f1';%Initial value for unknown coefficient
B0 =[-6.1e+04];%find the local fit using lsqcurvefit
options = optimoptions('lsqcurvefit','FiniteDifferenceType','central','OptimalityTolerance',1e-12,'FunctionTolerance',1e-12, 'MaxFunctionEvaluations',1500); lb = [-Inf]; ub = [Inf]; [B,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat] = lsqcurvefit(@firstorderDSC1,B0,T,f1,lb,ub,options); % Set up the problem for MultiStart
problem = createOptimProblem('lsqcurvefit','x0',B0,'objective',@firstorderDSC1,... 'lb',lb,'ub',ub,'xdata',T,'ydata',f1);ms = MultiStart('PlotFcns',@gsplotbestf);[xmulti,errormulti] = run(ms,problem,50);%plot the result
figure;plot(T,f1,T,firstorderDSC1(xmulti,T),'LineWidth',3)legend('Data','Fitted result')
Best Answer