How to save output of loop in matrix ?

11 vues (au cours des 30 derniers jours)
Govind Kumar
Govind Kumar le 20 Juin 2019
I have 1000*129*135 3D array. I want to store the output of following programe in matrix form.
for i=1:129 j=1:135;
b=a(:,i,j)
% some operation on b
c=output %after operation on b
end
I want to save output of all iteration in 129*135 matrix. How to do that?

Réponses (1)

Aravind Ravikumar
Aravind Ravikumar le 20 Juin 2019
Modifié(e) : Aravind Ravikumar le 20 Juin 2019
I am assuming the output from the operation (c) is a scalar. You could initialize a matrix, say
output_matrix = zeros(129,135);
Then you could assign output c to the respective index in the matrix. For example inside your for loop in the script you could insert the following code,
output_matrix(i,j) = c;
Your required matrix will be output_matrix.

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by