After curvefitting data, can I import the "fitresult" text (cfit) into the plot figure, also can I export the coefficients to excel
7 次查看(过去 30 天)
显示 更早的评论
ft = fittype( 'a*exp(-b*x)+c', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.StartPoint = [1 0.2 0.09];
[fitresult, gof, output] = fit( xData, yData, ft, opts );
h = plot(fitresult, xData, yData)
0 个评论
回答(1 个)
Javier Bastante
2016-3-16
Using this:
coef=coeffvalues(fitresult);
you can save your partameter values in a ROW variable called "coef". The order of the numbers is the order in which your parameters appear on your model (to see it you can use coeffnames(fitresult)).Once you've done this you can save them in excel using xlswrite:
xlswrite(filenamewithfullpath,variable,sheet,range)
So, in this case, for a file called example.xlsx saved in "C:\MATLAB\files\" and you want to save the coefficients in the second sheet, cells A1,A2 and A3 (COLUMN distribution) you must do this:
xlswrite(fillfile('C:\MATLAB\files','example.xlsx'),coef',2,'A1:A3')
You can have more info about all of this and more in:
help xlswsrite
or
doc xlswrite
The only important thing is that the Excel file must be closed. At least I've had always this problem.
If any of this desn't work or you have more questions, please don't hesitate and ask me.
Best Regards
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interpolation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!