MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   按我指定的顺序遍历某些整数 (https://www.labfans.com/bbs/showthread.php?t=26401)

poster 2019-12-14 20:13

按我指定的顺序遍历某些整数
 
正常循环是

for i=1:50 end 但是我想通过某些整数并按我指定的顺序执行循环

for i=4,3,45,34,23,31 end 如何在Matlab中做到这一点?



[B]回答:[/B]

这很简单:

for i = [4,3,45,34,23,31] Matlab中for的参数是一个矩阵。 1:50创建数字1..50的矩阵(向量)。这只是Matlab for -use的特例。



[url=https://stackoverflow.com/questions/5080191]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 05:06

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.