lsqcurvefit/lsqnonlin algorithm is not responding to the third unknown variable

I am trying to fit the equation , using optimization toolbox version 8.2, where a,b and c are 3 unknown variables. The fit gives almost correct result for first two variables; but the third one remains exatcly equal to the initial guess. The algorithm is fails to vary the last term. Note that, y data and x data are of the order of e-15 and e-8 respectively. a and b are also of the order of e-8. But c should vary between 0 to 1. My first initial guess for c is 0.81 and it remains the same after fitting. Kindly help me with this if possible.
With regards,
Sumit

 采纳的回答

Note that, y data and x data are of the order of e-15 and e-8 respectively.
Don't do that. Normalize your x and y data so that they are on the order of 1. Later, after you have fit the data, you can change the units of a and b to suit your original units of x and y if you wish.
options = optimset('TolFun',1e-50,'TolX',1e-50,'MaxFunEvals',2000,'MaxIter',2000);
These tolerances are meaningless. Double float precision only goes down to about
>> eps
ans =
2.2204e-16
After normalizing your data as recommended above, I would choose,
options = optimoptions('lsqcurvefit', 'FunctionTolerance',1e-12,'StepTolerance',1e-12,'OptimalityTolerance',1e-12);

5 个评论

Thanks Matt for your sugesstion. My x-data ranges from 1.95e-8 to 1e-5. With what value I should multiply x-data? Does this multiplication factor should be same for the y-data and a & b-coefficients also?
x and y don't have to be scaled the same. I would normalize both x and y so that each has a maximum of 1.
I have done the normalization as per your suggestion. It fits the data accurately and gives good result for c-coefficient. But now, it is producing unphysical result for a- and b-coefficients. I have tried several initial guesses. But everytime it is producing the same result: a,b,c=0.627,0.03,0.8. Accroding to my earlier unit syestem, the physically apriciable value should come around ~ 1e-9 to 2e-7 for a, 1e-8 to 1e-6 for b, 0 to 1 for c. What to do with these constrains and how to apply it here in the newly formated code? Kindly suggest.
Yes, but you have changed units in x and y. Therefore the units of a and b will have changed as well. As I said before, you can now just undo the model normalization. Specifically, if sy and sx are the normalization scale factors that you applied to x and y respectively, then you have now fit the model,
(y/sy)=2*A^2*(1-exp(-(x/xs)/B)^c)
so now just rewrite as,
y=2*(A^2*sy)*(1-exp(-(x/(sx*B))^c)
and make the parameter redefinitions,
a^2=A^2*sy
b =sx*B
and you will obtain a and b with respect to the original, unnormalized x and y.

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Least Squares 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by