How to put a list of different arrays, one after another, to create a new array ?
조회 수: 1 (최근 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 !
댓글 수: 0
채택된 답변
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
추가 답변 (1개)
Azzi Abdelmalek
2013년 5월 14일
편집: Azzi Abdelmalek
2013년 5월 14일
for i=1:10
y = myfunc();
data(i)= y
end
댓글 수: 2
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!