Hello, I am trying to fit a curve with non linear model (as shown in the caption). I used lsqcurvefit. The fitted curve is bad. How can I get a better fit and another question how can i fit two data simultaneously (same xdata but different ydata, for each ydata same function but i just want to change the value "80"). Thank you in advance. (the data is in attachment)
figure;A=importdata('ouss.xlsx');xdata = ... (A(:,1));ydata = ... (A(:,2));%%
% Create a simple exponential decay model.
fun = @(x,xdata)(x(1)*exp(-(x(2)*(80-x(4)))/(x(3)+80-x(4))))... ./(1+(xdata*(x(1)*exp(-(x(2)*(80-x(4)))/(x(3)+80-x(4))))./x(6)).^(1-x(5)));%%% Fit the model using the starting point
x0 = [2e+05,12.3,10.12,335,0.37,12.3];% x0 = [1,1,1,1,1,1];
options = optimoptions('lsqcurvefit','Algorithm','levenberg-marquardt','Display','iter','TolX', 1e-20, 'TolFun', 1e-20, 'MaxFunEvals', 40000, 'MaxIter', 4000000);lb = [1 1 1 1 0 1];ub = [1e17 100 100 1000 1 1e9];[x] = lsqcurvefit(fun,x0,xdata,ydata,lb,ub,options)%%% Plot the data and the fitted curve.
times = linspace(xdata(1),xdata(end));loglog(xdata,ydata,'ko',times,fun(x,times),'b-')legend('Data','Fitted exponential')title('Data and Fitted Curve')
Best Answer