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 Center および File ExchangeFile Operations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by