exponential curve fit coefficients
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Is there a way to calculate exponential curve fit coefficients without using the curvefit toolbox??
0 comentarios
Respuestas (2)
Star Strider
el 8 de Sept. de 2021
Editada: Star Strider
el 8 de Sept. de 2021
Linearising it by log-transforming the data is not appropriate, because that distorts the errors, making them multiplicative rather than additive.
It is straightforward to do a nonlinear parameter estimation using fminsearch, which is a core-MATLAB function, requiring no toolboxes.
EDIT — (8 Sep 2021 at 15:30)
To illustrate —
x = linspace(0, 5, 25);
y = x.^2 + randn(size(x));
y = abs(y);
objfcn = @(b,x) b(1).*exp(b(2).*x); % Objective Function
B0 = rand(3,1);
[B1,Fval] = fminsearch(@(b) norm(y - objfcn(b,x)), B0) % Nonlinear Iterative Solution
Fit1 = objfcn(B1,x);
B2 = polyfit(x, log(y), 1)
Fit2 = polyval(B2, x);
Fit2 = exp(Fit2);
figure
subplot(2,1,1)
plot(x, y, '.b')
hold on
plot(x, Fit1, '-r')
hold off
grid
title('Nonlinear Fit')
subplot(2,1,2)
plot(x, y, '.b')
hold on
plot(x, Fit2, '-r')
hold off
grid
title('Linearised Fit')
.
1 comentario
Ravi Narasimhan
el 8 de Sept. de 2021
Very interesting. I didn't know this was available in core Matlab. I thought (probably incorrectly) that the OP was looking for a quick and dirty solution where the linearization wasn't a big concern.
Ravi Narasimhan
el 8 de Sept. de 2021
Editada: Ravi Narasimhan
el 8 de Sept. de 2021
See the answer to a similar question in:
(corrected link)
0 comentarios
Ver también
Categorías
Más información sobre Interpolation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!