MATLAB: How to access the result of Curve Fit App in the workspace

curve fit app generator code cfit object

I have some experimental data that I would like to create a curve fit. Using the Curve Fit App I obtain a good result like that
But I dont know how to use the values of the curve in my script, I need to use the curve to find the peaks. I have try to use the generator code tool, but the result is completily different, it seems like a not so good interpolation like the Curve Fit App. I just want to access the curve fit result of Curve Fit App. Please, help me.
Thanks.

Best Answer

Hi,
when you are in the fitting app right click on the model you want to export:
.
then choose all options:
.
now you have the model, output and goodness in your workspace. To access the coefficients of the fitted model use:
>> coeffvals = coeffvalues(fittedmodel)
coeffvals =
0.3768 1.4162 2.3424
To get some values from the goodness (for example the R-square value) use:
>> r_square = goodness.rsquare
r_square =
0.9985
like shown here:
.
Best regards
Stephan