フィルターのクリア

how do I store and use fitobjects

7 ビュー (過去 30 日間)
Allen
Allen 2017 年 1 月 20 日
回答済み: Sindhuja Parimalarangan 2017 年 1 月 23 日
For reasons I won't go into I need to store a series of curve fits and plot them all at once.
I calculate a fit to a set of points as follows:
f{i} = fit(x,y,fitModel,fitOptions)
and then plot it using
plot(f{k}, cmap(k,:));
but I get the message
Error using cfit/plot>parseinput (line 328)
Must specify both XDATA and YDATA.
Error in cfit/plot (line 42)
[S1,xdata,ydata,S2,outliers,S3,ptypes,conflev] =
parseinput(alltypes,varargin);
If I look at f{i} , e.g. f{1}:
>> f{1}
ans =
Linear model Poly1:
ans(x) = p1*x + p2
Coefficients (with 95% confidence bounds):
p1 = 92.11 (60.03, 124.2)
p2 = 3.611 (-1.991, 9.212)
If I just do f = fit(x,y,fitModel,fitOptions) and plot(f,cmap(k,:)) it works just fine.
How do I store the curves and then plot them all later in the script?

回答 (1 件)

Sindhuja Parimalarangan
Sindhuja Parimalarangan 2017 年 1 月 23 日
You could store all the curve fit objects as elements of a cell arrays and then use cellfun to plot all the elements as shown in the following example :
load hahn1
f{1} = fit( temp, thermex, 'rat23' )
f{2} = fit( temp, thermex, 'exp2' )
f{3} = fit( temp, thermex, 'fourier3' )
%%plotting the above curves together %%
figure
hold on
cellfun(@plot,f)
colormap and "ColorOrder" property of plot function maybe useful to enhance the plot.

カテゴリ

Help Center および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by