My for loop is replacing all values of my array with the last iteration.
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!