fitting data with equation

Hi guys, so I have alot of experimental data in column matrix y. And I want to use the equation below to find the best fit for my data y. This means have constant b adjusted with x varying, I know that x typically ranges from 1 to 5 with y and b ranges from 0 to 2.
I'm thinking of using a double loop. Would anyone give me tips on how to solve for it effectively? Thanks in advance. The equation is:
y= (1-0.05*x^(b))/(1-0.05*x^b)^2

 Risposta accettata

Star Strider
Star Strider il 29 Mag 2015
I would use a nonlinear curve fitting function such as nlinfit, lsqcurvefit (or fminsearch indirectly).
However if your (x,y)>0, are not noisy, y>1, and you want an estimate of ‘b’, this might work:
b = log(20*(1-1./y))./log(x);
Otherwise, use a nonlinear parameter estimation routine.

4 Commenti

sarah
sarah il 30 Mag 2015
Modificato: sarah il 30 Mag 2015
Thanks.
What if I want to put in all the values of y into the equation, and i know the range for b and want it to estimate for x. However how can matlab tell me the error for each value?
I got the impression that ‘x’ is your independent variable, ‘y’ is your dependent variable, and you wanted to estimate the parameter ‘b’.
If you know ‘y’ and ‘b’ and you want to estimate ‘x’ I would still prefer a nonlinear parameter estimation routine. However, with the appropriate assumptions and reservations as I mentioned earlier, a bit of algebra produces this simplified expression:
x = (20-(1./y)).^(1./b);
The error for estimates of ‘x’ would be easiest to calculate using your original equation with the Statistics Toolbox nlinfit function, then nlparci, since x appears to be a parameter.
sarah
sarah il 30 Mag 2015
And may I ask how did you derive this expression? Thanks
Sure!
y = (1-0.05*x^b)/((1-0.05*x^b)^2
(1/y) = 1-0.05*x^b
(1-(1/y))*20 = x^b
x = ((1-(1/y))*20)^(1/b)
Then vectorise it to do the calculation:
x = ((1-(1./y))*20).^(1./b);

Accedi per commentare.

Più risposte (0)

Categorie

Community Treasure Hunt

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

Start Hunting!

Translated by