Difference between predefined and custom exponential fit function
이전 댓글 표시
Hello all, I'm trying to define a custom function for fitting some data, of the shape a+b*exp(c*x). But to test whether Im' doing this correctly, I first tried to compare fitting a simple dataset with a predefined expoinential "exp1", and the one that I'd define myself.
x = 1:100;
y = 3*exp(0.2*x); % some random exponential data
f1 = fit(x', y', 'exp1')
This gives the output of
General model Exp1:
f1(x) = a*exp(b*x)
Coefficients (with 95% confidence bounds):
a = 3 (3, 3)
b = 0.2 (0.2, 0.2)
which is correct.
Now, defining the same thing with fittype:
testexp = fittype('a*exp(b*x)', 'independent', 'x');
f2 = fit(x', y', testexp)
gives the output of
General model:
f2(x) = a*exp(b*x)
Coefficients (with 95% confidence bounds):
a = -3.317e-19 (-1.473e-17, 1.407e-17)
b = 0.9402 (0.5052, 1.375)
which is slightly insane.
Can you please tell me what am I doing wrong?
Kind regards, Marko
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!