Afficher commentaires plus anciens
for文において下記のように書くと
for c=1:4
end
1~4までループさせる事が出来ると思います。
ですが、私は下記に書くように
for c=1:4 r=:1:4:40
end
cとrの二つのループを同じタイミングで進ませたいのですが何か方法はありますでしょうか?
Réponse acceptée
Plus de réponses (1)
操作内容によりますが基本的には難しいです。
c と r を同時に処理する場合、c = 1のときでも r は10この処理をそれぞれ行う必要があります。
なので以下のようにforの中にforで囲うのが一般的です
for c = 1:4
for r = 1:4:40
COMMAND;
end
end
----------------------------
X = {5:5:100, 10:10:100, 20:20:100};
Y = {rand(1,20), rand(1,10), rand(1,5)};
figure
hold on
p = cellfun(@plot,X,Y);
1 commentaire
朋貴 熊田
le 30 Sep 2021
Catégories
En savoir plus sur ループと条件付きステートメント dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!