MATLAB: How to get/save Curve Fitted Model data into Workspace with .mat file

curve fittingMATLAB

Hello Everyone,
I used curve fitting toolbox in Matlab 2012b. I fitted the curve on my data with any model like Polynomial, Fourier or any. I want to save Polynomial, Fourier model data as .mat file for further processing.
I am new in this environment, help, suggestion and comments would be highly appreciation
Thanks in advance !!

Best Answer

Shara, you could simply use the save command:
x = 0:0.1:pi;
y = sin(x);
ft = fittype('poly4');
[fitresult, gof] = fit(x',y','poly4');
save('mymat.mat','fitresult','ft','gof','x','y')
Alternatively, if the variables are in the workspace, select them, and do a mouse right-click to save.
Retrieve the mat file using
load('mymat.mat')