I am trying to create a solver that will fit the following. Y data has been normalised to 1.
param0 = 0;opts = optimset('lsqnonlin'); % method
opts.Algorithm = 'levenberg-marquardt';opts.Display = 'iter';TR=0.0055Xk = [0.0785398163397448 0.165806278939461 0.235619449019234 0.270526034059121 0.523598775598299];Yk = [0.451237263464338 0.810771470160116 0.965065502183406 1 0.991266375545852]modelfun = @(a) ((1-exp(-TR/a))*sin(Xk)) ./ (1-cos(Xk)*exp(-TR/a)) - Yk;[estcoefs,resnorm,residual,exitflag,output] = lsqnonlin(modelfun,param0,[],[],opts);
I am getting unrealistic values from using lsqnonlin. For this data, I know the result should be 0.08. This can be verified if I put 0.08 into the model and compare with the data.
plot(Xk,Yk,'b')plot(Xk,((modelfun(estcoefs))+Yk)/max(modelfun(estcoefs)+Yk),'r');plot(Xk,(modelfun(0.08)+Yk)/max(modelfun(0.08)+Yk),'g')
Can anyone help me with this issue?
Best Answer