Storing matrices in cells

2 visualizaciones (últimos 30 días)
stelios loizidis
stelios loizidis el 17 de Jun. de 2022
Respondida: Chunru el 17 de Jun. de 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!

Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre Elementary Math en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by