How to repeat a for loop n times
Ältere Kommentare anzeigen
end
States
Basically it outputs an array of size (N,1) consisting of 1s and -1s.
How can I repeat this array for example 5 times using the updated values of 'States', whilst displaying the results of each loop?
1 Kommentar
James Tursa
am 30 Nov. 2016
"... using the updated values of 'States' ..."
What does this mean? I don't see 'States' used anywhere in the loop. Certainly you could wrap your current loop inside another loop, but how is 'States' supposed to be used in this loop?
Akzeptierte Antwort
Weitere Antworten (2)
Simply include in a for loop:
n = 5;
for k = 1:n
.... your code
end
1 Kommentar
Karthika AR
am 29 Sep. 2020
Thank you
Above loop can be simply
states=2*(cdf('norm',z,0,1)>rand(size(z)))-1;
To repeat, simply incorporate in a loop save each trial as a new column in 2D array would be simplest.
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!