How to do exponential curve fitting like y=a*exp(-b/x)

6 views (last 30 days)
I can't linearization of this equation.y=a*exp(-b/x). I want to make the eqn like y=mx+c. Then find out the value of a and b by solving two matrix by matlab. Can anyone help me? Thanks in advance.

Accepted Answer

Matt J
Matt J on 1 Aug 2021
If you make the change of variables u=log(y), c=log(a) and v=1/x, then your exponential equation becomes u=c-b*v which is linear in u and v. However, this is usually recommended only as a way of initializing an iterative fit. The latter you can do either with fit(), lsqcurvefit(), or some File Exchange options like fminspleas.
  4 Comments
Matt J
Matt J on 1 Aug 2021
You are quite welcome, but please Accept-click the answer if it helped you.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 1 Aug 2021
I would recommend using fitnlm() instead. It's pretty much just as easy and it probably gives you a better fit.
% Define the model as Y = a * exp(-b/x) + c
modelfun = @(b,x) b(1) * exp(-b(2) ./ x(:, 1)) + b(3);
% Now the next line is where the actual model computation is done.
mdl = fitnlm(tbl, modelfun, beta0);
% Now the model creation is done and the coefficients have been determined.
% Extract the coefficient values from the the model object.
% The actual coefficients are in the "Estimate" column of the "Coefficients" table that's part of the mode.
coefficients = mdl.Coefficients{:, 'Estimate'}
Full demo is attached.

Categories

Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!