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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That’s easy:
The argument to
forin Matlab is a matrix. 1:50 creates a matrix (vector) of numbers 1..50. It is just a special case of Matlabfor-usage.