Storing matrices in cells

조회 수: 6 (최근 30일)
stelios loizidis
stelios loizidis 2022년 6월 17일
답변: Chunru 2022년 6월 17일
Hello,
I have the following code:
for i=1:20
%psudoinverse
pH_matrix=pinv(H_matrix); % H_matrix: 1X20
B=pH_matrix*Y(i,:); % Y:20X24
end
Based on the above code, when the for-loop ends, B will have dimensions 20x24. How can I store matrix B for each iteration? That is, when the for-loop is over, to have 20 times the matrix B which has dimensions 20X24. Also, the results from each iteration can be stored in a cell; That is, cell 1 has the results of B (20X24) from the first iteration, cell 2 has the results of B (20X24) from the second iteration and so on.
Your help is invaluable!

채택된 답변

Chunru
Chunru 2022년 6월 17일
for i=1:20
%psudoinverse
pH_matrix=pinv(H_matrix); % H_matrix: 1X20
% You can use cell array to store the result for each iteration
B{i} =pH_matrix*Y(i,:); % Y:20X24
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by