Storing matrices in cells

6 Ansichten (letzte 30 Tage)
stelios loizidis
stelios loizidis am 17 Jun. 2022
Beantwortet: Chunru am 17 Jun. 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!

Akzeptierte Antwort

Chunru
Chunru am 17 Jun. 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

Weitere Antworten (0)

Kategorien

Mehr zu File Operations finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by