Azzera filtri
Azzera filtri

Using Cftool can I change the default fit options

3 visualizzazioni (ultimi 30 giorni)
Liam
Liam il 13 Gen 2016
Risposto: Tushar Sinha il 15 Gen 2016
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

Risposte (1)

Tushar Sinha
Tushar Sinha il 15 Gen 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

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by