开发者

Loop through certain integers and in the order that I specify

开发者 https://www.devze.com 2023-02-12 09:11 出处:网络
The normal loop is for i=1:50 end but I want to ex开发者_JAVA技巧ecute the loop through certain integers and in the order that I specify

The normal loop is

for i=1:50

end

but I want to ex开发者_JAVA技巧ecute 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号