Azzera filtri
Azzera filtri

how to create two counter loops that run at the same time in matlab??

3 visualizzazioni (ultimi 30 giorni)
hello every one, how to create two counter loops that start at the same time in matlab editor and gets applied on given code at the same time using for loop??
for example: counter "1" should run like 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16. counter "2" should run like 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4. for the same code, kindly help me.

Risposta accettata

Stephen23
Stephen23 il 4 Feb 2016
This loop:
for m = 1:16
n = 1+mod(m-1,4);
disp([m,n])
end
displays the variables m and n in the command window:
1 1
2 2
3 3
4 4
5 1
6 2
7 3
8 4
9 1
10 2
11 3
12 4
13 1
14 2
15 3
16 4

Più risposte (1)

Jason Platzer
Jason Platzer il 22 Feb 2018
Thanks very much. This was very helpful.

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by