I am trying to solve a least square non linear regression with the following data points:
X 1 2 3 4 5 6 7 8 9 10 Y 2950 2452 2333 2274 2244 2222 2207 2195 2184 2176
The equation which I want to fit is:
a, b and c are constants defined to fit the curve..
Also, as you notice, the Y value decreases with each X, but it will gradually converge and not decrease after a certain value of X. So, I want to extrapolate the curve such that, at very high value of X (X = infinity), function Y converges to its asymptotic value.. In other words, with a certain high number of 'X', the "a*exp[-X/b]" term will tend toward 0, where "c" represents the convergence, and that value of "c" is being taken as final result..
Any type of help is appreciated.. Thanks for your consideration
No products are associated with this question.
Here's a poor man's approach using FMINSEARCH, assuming,you don't have the Optimization Toolbox. If you do have the toolbox, LSQCURVEFIT would be worth a try.
p0(3)=1000; z=[ones(10,1) , -X(:)]\log(Y(:)-p0(3));
%Solve p=fminsearch(@(p) norm( p(1)*exp(-X/p(2))+p(3) - Y), p0,optimset('MaxFunEvals',100000));
a=p(1), b=p(2), c=p(3)
Play games and win prizes!Learn more