Reputation: 457
I have a table with 2 column, c1 and c2 in Matlab. I want to use the Curve Fitting Tool to fit the exponential equation into my data.
Right now I have this in my code: cftool(c1,c2);
this code is going to open cftool and fit the polynomial curve! However I want it as an Exponential curve! How can I do that?
Upvotes: 1
Views: 2243
Reputation: 18484
The key is to have the data to be fit in your workspace and choose the X data and Y data first. Then the dropdown menu will show "Exponential" as an option. From this documentation page:
- Open the Curve Fitting app by entering
cftool
. Alternatively, click Curve Fitting on the Apps tab.- In the Curve Fitting app, select curve data (X data and Y data, or just Y data against index).
Curve Fitting app creates the default curve fit,Polynomial
.- Change the model type from
Polynomial
toExponential
.
To see the code used by cftool
for fitting your data, select File > Generate Code after you've configured all of the options and are satisfied with the results. You can then use and modify this code for your application instead calling cftool
. In the case of a simple exponential fit, it looks like the fit
function is used with options specified via fittype
and fitoptions
.
Upvotes: 0
Reputation: 826
Is that what you want?
f = fit(x,y,'exp1');
You can also customize:
myfit = fittype('a*u+b*exp(n*u)',...
'problem','n',...
'independent','u');
to use f=fit(x,y,'myfit');
You can read about it here and here
Upvotes: 1