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

4 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

Stephen23
Stephen23 am 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

Weitere Antworten (1)

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

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by