The normal loop is
for i=1:50
end
but I want to execute the loop through certain integers and in the order that I specify
for i=4,3,45,34,23,31
end
How can I do that in Matlab?
That's easy:
for i = [4,3,45,34,23,31]
The argument to for
in Matlab is a matrix. 1:50 creates a matrix (vector) of numbers 1..50. It is just a special case of Matlab for
-usage.
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