필터 지우기
필터 지우기

concatenate in for loop

조회 수: 3 (최근 30일)
N
N 2014년 8월 19일
댓글: N 2014년 8월 19일
Hi, I have a problem with making the combination of cell arrays in a loop. My code is:
for j = 1:width(1)
one{j} = [extensionmean{j,1};extensionmean{j,2};extensionmean{j,3};extensionmean{j,4};extensionmean{j,5}];
end
this works, but I want something extra however. The amount of extensionmean is often unknown. so now I wrote the extensionmean {j,x} five times. But this could be six or four another time. I would like to make this part automatic as well, so make it in a loop that loops through all the extensionmean parts. Is this possible to do with a for loop? I tried but it didn't give me the right answer. I just don't want to keep writing the extensionmean or adapting it: try code:
for j = 1:width(1)
for i = 1:length(extensionmean)
one{j} = [extensionmean{j,i};];
end
end
thanks in advance for any help

채택된 답변

Guillaume
Guillaume 2014년 8월 19일
for j = 1:size(extensionmean, 1)
one{j} = vertcat(extensionmean{j, :});
end
Should do it.
  댓글 수: 1
N
N 2014년 8월 19일
That does it !! thank you so much !!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by