Storing matrices in cells

6 visualizzazioni (ultimi 30 giorni)
stelios loizidis
stelios loizidis il 17 Giu 2022
Risposto: Chunru il 17 Giu 2022
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!

Risposta accettata

Chunru
Chunru il 17 Giu 2022
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

Più risposte (0)

Categorie

Scopri di più su File Operations in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by