Nonlinear least square regression
显示 更早的评论
i have (x , y) data
the function between x and y is y = 0.392* (1 - (x / b1) .^ b2
i want to use nonlinear least square regression to obtain the values of b1 and b2
can any one help me with the structure of the Matlab program
thanks in advance
1 个评论
回答(1 个)
the cyclist
2013-5-27
If you have the Statistics Toolbox, then you can use the nlinfit() function.
Type
doc nlinfit
8 个评论
NLINFIT seems to think that y(t) = .392* exp(-t) is a pretty good model for your data. Note that this is the same as
y(t) = lim_n-->inf 0.392*(1+t/n)^n
so the fitting algorithm will obviously look for large x(i) in your proposed model. Your data does look vaguely exponential...
ameen
2013-5-27
which one is correct ???
Both of them. As you can see from running the code below, they both produce virtually identical curves. Again, this is because making your parameters large causes the curve to converge to 0.392*exp(-t).
t=sort(t);
f=@(t,x) 0.392*(1-(t./x(1))).^x(2);
beta=[1.9793 2.0014]*1e9;
x =[258.1339 261.1441];
plot(t,f(t,beta), '*-' ,t,f(t,x),'o--',t,0.392*exp(-t),'d-.')
legend('Using Beta','Using x','Using 0.392*exp(-t)')
ameen
2013-5-27
Or your model. Maybe you should be fitting
y=x(1)*exp(-x(2)*t)
类别
在 帮助中心 和 File Exchange 中查找有关 Nonlinear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!