how to use cftool non-interactively in matlab

岁酱吖の 提交于 2020-01-24 12:20:11

问题


Is there any way to use cftool non-interactively. For example, given x, y and the fitting function, calling cftool to generate and returned the fitted data without using opening the toolbox GUI. Thanks


回答1:


You can use the fit function that comes with Curve Fitting Toolbox. To find out more, type doc fit. Or you can use cftool interactively, then use Generate Code from the File menu to create a function that uses the fit command to repeat your interactive work programmatically. Use this as a template example.




回答2:


I don't know, but there's another way.

File/Generate Code




回答3:


function [fitresult, gof] = Custom_fit(x,y,My_Equation)

% example -->My_Equation = 'a*exp(-b*x)+c*exp(-d*x)' % y=f(x)

[xData, yData] = prepareCurveData( x, y );

% Set up fittype and options.
ft = fittype(My_Equation, 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.StartPoint = [0.0376273842264444 0.821185653244809 0.81656489972889 0.961898080855054];

% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts );

end

code.



来源:https://stackoverflow.com/questions/10890438/how-to-use-cftool-non-interactively-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!