exponential curve fit coefficients

조회 수: 18 (최근 30일)
Jamie Williamson
Jamie Williamson 2021년 9월 8일
댓글: Ravi Narasimhan 2021년 9월 8일
Is there a way to calculate exponential curve fit coefficients without using the curvefit toolbox??

답변 (2개)

Star Strider
Star Strider 2021년 9월 8일
편집: Star Strider 2021년 9월 8일
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
B1 = 3×1
1.4102 0.5850 -1.0206
Fval = 7.3191
Fit1 = objfcn(B1,x);
B2 = polyfit(x, log(y), 1)
B2 = 1×2
0.9478 -0.9879
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
Ravi Narasimhan
Ravi Narasimhan 2021년 9월 8일
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
Ravi Narasimhan 2021년 9월 8일
편집: Ravi Narasimhan 2021년 9월 8일

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by