How to create a structure of matrices within a loop
조회 수: 6 (최근 30일)
이전 댓글 표시
Dear all,
Using the following code, I would like to create a structure containing 3 matrices that are the result of a loop. I want these matrices to be named within this structure, e.g. 'A', 'B' and 'C'. What should I improve in my code?
for s0 = 1:3
matrixOfCodes = cell(size(matrixOfNames,2), length(codePart1));
for s1 = 1:size(matrixOfNames,2)
for s2 = 1:length(codePart1)
fullPath = strcat(codePart1{s2}, matrixOfNames{s0,s1}, codePart2{s2});
matrixOfCodes{s1, s2} = fullPath;
end
end
m{s0} = matrixOfCodes;
matrixOfCodes = [];
end
댓글 수: 0
채택된 답변
추가 답변 (1개)
Joanna Przeworska
2021년 3월 2일
댓글 수: 2
Stephen23
2021년 3월 2일
@Joanna Przeworska: I fixed my answer. You will need this:
m.(database{s0}) = ..
% ^^^^ index
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!