Using Cftool can I change the default fit options

2 views (last 30 days)
I am using the cftool to repeatedly fit different data sets that are similar, using a custom equation. Once I have fitted a dataset I then want to keep the fit options and equation the same and load in the next dataset. Is there anyway to change the default fit options for a custom equation/ prevent the fit options being reset to the defaults of -Inf and Inf?
Thanks

Answers (1)

Tushar Sinha
Tushar Sinha on 15 Jan 2016
Hi Liam,
Once you have selected the "fitoptions", you can generate MATLAb code using the "File->Generate Code" in CF Tool GUI. Now, you can use this code to fit other datasets. The "fitoptions" will not change unless you change the code.
The generated code will look something like:
ft = fittype( 'poly1' );
opts = fitoptions( 'Method', 'LinearLeastSquares' );
opts.Lower = [-12 -Inf];
opts.Upper = [12 Inf];
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts );
Now you can simple change "xData" and "yData" to fit new data without changing options.
I hope this helps you.
Thanks,
Tushar

Tags

Community Treasure Hunt

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

Start Hunting!