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

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 !

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 6 月 7 日
編集済み: Azzi Abdelmalek 2013 年 6 月 7 日
Edit
data=[];
for i=1:21
a = handles.models(i).gmm;
b = a.mu';
SV = b(:)';
data=[data;SV]
end

8 件のコメント

Stamatis Samaras
Stamatis Samaras 2013 年 6 月 7 日
could work if i had known y1,y2,..yN forehand ,thus i assign values on them through myfunc()
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 6 月 7 日
What do you mean?
Stamatis Samaras
Stamatis Samaras 2013 年 6 月 7 日
I have 21 1x69 arrays created inside my for loop and i want to put each one of these arrays one below another, to create a 21x69 final array.Your answer seems to work but I need to fit it in my problem where I dont know y1,y2,..,yN outside of for loop
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 6 月 7 日
Do you know the names of these variables?
Stamatis Samaras
Stamatis Samaras 2013 年 6 月 7 日
For each iteration inside for loop 1x69 is assigned to a variable called SV
Stamatis Samaras
Stamatis Samaras 2013 年 6 月 7 日
編集済み: Azzi Abdelmalek 2013 年 6 月 7 日
for i=1:21
a = handles.models(i).gmm;
b = a.mu';
SV = b(:)';
data=??;
end
data=[];
for i=1:21
a = handles.models(i).gmm;
b = a.mu';
SV = b(:)';
data=[data;SV]
end
Stamatis Samaras
Stamatis Samaras 2013 年 6 月 7 日
Thanks a lot Azzi !

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

その他の回答 (1 件)

Iain
Iain 2013 年 6 月 7 日
array = [];
for i = 1:10
...
array = [array; addthis];
...
end

3 件のコメント

Stamatis Samaras
Stamatis Samaras 2013 年 6 月 7 日
I dont understand what you mean with "addthis"
Iain
Iain 2013 年 6 月 7 日
It is whatever you want to add to the bottom of the array, whether its a new row, or 15 new rows.
Stamatis Samaras
Stamatis Samaras 2013 年 6 月 7 日
i got it a while ago with Azzi's help,thanks for your help too

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

カテゴリ

ヘルプ センター および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by