Difference between predefined and custom exponential fit function
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Linear and Nonlinear Regression in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!