开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜