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

8 views (last 30 days)
Atiqur Rahman on 1 Aug 2021
Commented: Atiqur Rahman on 1 Aug 2021
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.

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.
Matt J on 1 Aug 2021
You are quite welcome, but please Accept-click the answer if it helped you.

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. Atiqur Rahman on 1 Aug 2021
Thanks a lot. I solved my problem. Thanks again.