How to do exponential curve fitting like y=a*exp(-b/x)
24 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Matt J
le 1 Août 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 commentaires
Plus de réponses (1)
Image Analyst
le 1 Août 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.
Voir également
Catégories
En savoir plus sur Linear Algebra dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!