My for loop is replacing all values of my array with the last iteration.
Afficher commentaires plus anciens
The point of this loop is to create multiple square 4X4 matrices stored in one variable A, for which the 2 values in the matrix change and are extracted from a 3X20 matrix I have previously created. My for loop, below keeps creates a cell array with 60 elements (like I want) but when the loop is done all the values change to the very last. How can I keep this from happening?
if true
% for i=1:a
for j= 1:b
for k=1:(a*b)
A{k}=[0,1,0,0;-1,0,msigmasq(i,j),0;0,0,0,1;1,0,mplus1sigmasq(i,j),0]
A{1}
end
end
end
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!