Possible Duplicate:
How do I iterate through each element in an n-dimensional matrix in MATLAB?
I have a column vector list which I would like to iterate like this:
for elm in list
//do something with elm
How?
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.
In Matlab, you can iterate over the elements in the list directly. This can be useful if you don’t need to know which element you’re currently working on.
Thus you can write
Note that Matlab iterates through the columns of
list, so iflistis a nx1 vector, you may want to transpose it.