vertical concatenation of matrices in a loop

조회 수: 1 (최근 30일)
Yuvashree Mani Urmila
Yuvashree Mani Urmila 2014년 6월 13일
편집: Mischa Kim 2014년 6월 13일
I have a set of matrices saved in a data structure. I need to vertically concatenate the matrices. The number of columns is consistent for every matrix. how is it possible to do this in the loop i have written here. thanks
for fileNr =1:8
outputFileName = outputFileNames(fileNr);
outputFileName = outputFileName{1};
outputFileName = strcat(outputFolder, filesep, outputFileName);
FileName=(outputFileName);
FileName
data1=load(FileName);
data=data1.dataStruct.data;
end

채택된 답변

Mischa Kim
Mischa Kim 2014년 6월 13일
편집: Mischa Kim 2014년 6월 13일
Yuvashree, try
data = [];
for fileNr = 1:8
[...] % removed code for better readability
data1 = load(FileName);
if (rem(fileNr,8)==0) % save every 8th matrix
data = [data; data1.dataStruct.data];
end
end
  댓글 수: 2
Yuvashree Mani Urmila
Yuvashree Mani Urmila 2014년 6월 13일
편집: Yuvashree Mani Urmila 2014년 6월 13일
that works. Thanks for the help. what should be done if i want to do the samething for every 8 matrices and store them using different variables.
for eg data1=[data; data1.dataStruct.data]; (for first8 matrices)
data2=[data; data1.dataStruct.data]; (for second8 matrices)
datan=[data; data1.dataStruct.data]; (for last8 matrices)
Mischa Kim
Mischa Kim 2014년 6월 13일
See updated answer above.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by