フィルターのクリア

Using ifelse in a loop - possible?

1 回表示 (過去 30 日間)
Jonas Maurer
Jonas Maurer 2017 年 12 月 7 日
コメント済み: KL 2017 年 12 月 7 日
Dear all,
is it possible to put "IFELSE" into a loop? I struggled. Mybe there is a trick?
happy for every answer! Tnaks a lot!
Jonas
  1 件のコメント
Birdman
Birdman 2017 年 12 月 7 日
Of course possible, why not? What is your exact question?

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

採用された回答

KL
KL 2017 年 12 月 7 日
You need to use indexing.
here is a small example. I'm gonna create a vector with 1s and 0s. In the for loop, I'll check if "an element" is either 1 or 2 and display a message.
dummy = [1 0 0 1 1 0 1 0 1 1 0 1];
for element_no = 1:numel(dummy)
if(dummy(element_no)==1)
disp('one')
else
disp('zero')
end
end
  2 件のコメント
Jonas Maurer
Jonas Maurer 2017 年 12 月 7 日
Thanks very much KL. I´ll try this one...
KL
KL 2017 年 12 月 7 日
You're welcome. Please read the link I gave you and also the getting started exercises. They have examples for every question that you may have,

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by