Is it possible in Octave to made 2 loops in the same time like :
(for i=0:10 && j=10:20)
i;
j;
end
If the loops are of the same length, then yes. Not well known is that for non-vectors, a for loop, loops over columns. So just place your vectors in a matrix, one row per variable:
for r = [0:10; 10:20]
printf ("1st is %2i; 2nd is %2i\n", r(1), r(2));
endfor
which returns:
1st is 0; 2nd is 10
1st is 1; 2nd is 11
1st is 2; 2nd is 12
1st is 3; 2nd is 13
1st is 4; 2nd is 14
1st is 5; 2nd is 15
1st is 6; 2nd is 16
1st is 7; 2nd is 17
1st is 8; 2nd is 18
1st is 9; 2nd is 19
1st is 10; 2nd is 20
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With