フィルターのクリア

execution of for loops on specific numbers

1 回表示 (過去 30 日間)
Raghavendra Reddy P
Raghavendra Reddy P 2015 年 5 月 11 日
コメント済み: Purushottama Rao 2015 年 5 月 11 日
k=[3 8 10 12]
i wanted to execute above mentioned indexes in for loop something like this
for i=[3 8 10 12]
if i==3
do stuff
end
if i==10
do stuff
.
.
.
if i==12
do stuff
end
end
i don't know vector k elements before hand.
  3 件のコメント
Guillaume
Guillaume 2015 年 5 月 11 日
編集済み: Guillaume 2015 年 5 月 11 日
@Michael, yes it's the same for a hardcoded k, but if k is an input to the function, then it's not:
k = randi(3, 1, 5);
for action = k
switch action
case 1
disp('do action 1');
case 2
disp('do action 2');
case 3
disp('do action 3');
end
end
Like you though, I've no idea what Raghavendra is asking.
Purushottama Rao
Purushottama Rao 2015 年 5 月 11 日
i think he has already got the answer through other post.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by