フィルターのクリア

How to put a list of different arrays, one after another, to create a new array ?

3 ビュー (過去 30 日間)
What I am asking is similar to this example,
I have y1,y2,y3 manually created and I want my final array to be
data = [y1,y2,y3];
How am i supposed to do the same thing inside a for loop ?
for i=1:10
y = myfunc();
data = ??
end
I hope you understood what I cant do and I sincerely hope this can be done someway.
P.S.: I am aware of allocating memory space for the dynamically created array data
Thanks for your time in advance !

採用された回答

Matt J
Matt J 2013 年 5 月 14 日
You haven't said whether y1,y2,y3 are scalar or not. If not,
data=cell(1,10);
for i=1:10
data{i} = myfunc();
end
y=[data{:}];
  3 件のコメント
Matt J
Matt J 2013 年 5 月 14 日
Then you have your Answer.
Stamatis Samaras
Stamatis Samaras 2013 年 5 月 14 日
yes it works, thanks a lot !

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

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 5 月 14 日
編集済み: Azzi Abdelmalek 2013 年 5 月 14 日
for i=1:10
y = myfunc();
data(i)= y
end
  2 件のコメント
Stamatis Samaras
Stamatis Samaras 2013 年 5 月 14 日
sorry Azzi but this wont work i is different from the number of elements in y
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 5 月 14 日
Matt's answer may help

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

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by