How to create array, cell or structure, of cfit objects?

I would like to figure out how to make an cell or structure of cfit objects.
For simple visualization of what I'm trying to do:
for i=1:10
Fits(i)=fit(Xdata,Ydata(i),fittype)
end
However, in the above accepted answer, it was suggested to fill up a cell element with the cfit object. I keep getting the following error: "Conversion to cell from cfit is not possible" When trying something similar, such as:
Fits=cell(1,10)
for i=1:10
Fits(i)=fit(Xdata,Ydata(i),fittype)
end
Your suggestions are appreciated!

 採用された回答

per isakson
per isakson 2014 年 7 月 16 日
編集済み: per isakson 2014 年 7 月 16 日

1 投票

Try to replace
Fits(i)=fit(Xdata,Ydata(i),fittype)
by
Fits{i} = fit(Xdata,Ydata(i),fittype);

1 件のコメント

James
James 2014 年 7 月 16 日
isakson ~ I cellute you!
Tisk tisk on me, I should have figured this one out. Obviously, haven't worked much with cells before. Thanks for the documentation link as well.

サインインしてコメントする。

その他の回答 (1 件)

Ramy Rabie
Ramy Rabie 2020 年 5 月 19 日

0 投票

To Convert the fitted line to a -friendly- array :
fitted_Line_Array = feval( cfitobj , 0:length(data)-1 )
plot(fitted_Line_Array)
feval is used to evaluate a value on the fitted curve. we will use entire xaxis to create it ( like a plot )
Idk if there's a special function to do it faster than this. but I couldn't fint this answer in Matlab Answers so I put it here if someone was looking for it.

カテゴリ

ヘルプ センター および File ExchangeData Type Identification についてさらに検索

製品

質問済み:

2014 年 7 月 15 日

回答済み:

2020 年 5 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by