How to do exponential curve fitting like y=a*exp(-b/x)
22 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Atiqur Rahman
am 1 Aug. 2021
Kommentiert: Atiqur Rahman
am 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.
0 Kommentare
Akzeptierte Antwort
Matt J
am 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 Kommentare
Weitere Antworten (1)
Image Analyst
am 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.
Siehe auch
Kategorien
Mehr zu Linear Algebra finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!