フィルターのクリア

Why doesn´t it stop the loop?

2 ビュー (過去 30 日間)
Jonathan Babitsch
Jonathan Babitsch 2020 年 6 月 18 日
コメント済み: Jonathan Babitsch 2020 年 6 月 18 日
Hi everybody,
I have a probably pretty stupid question, but I have no Idea what my problem is here.
In the following Code I was trying to say if whatever is in the if codition is true, don´t advance checking if the condition is true in the next loop. So I was trying to escape the loop by saying If it is true one time, set huellkoerper=4 to end the inner for loop.
Thing is now. If one of the points described by allepunkte fullfills the condition in the If-Condition, it shouldn´t further check in the upcoming huellkoerper.
Anyway, if I let it run it tells me this:
That point 4 and eight are both inside body 1 and 2. This is right, but my goal is not to count twice. So if anything is Inside Body 1, don´t check for body 2. If something is in body 2, don´t check for body3. Why does it do so in this case? Why doesn´t the programm escape the inner for loop?
I´m so glad for any advice or help. Thank you guys a lot in advance!
Johnny

採用された回答

David Hill
David Hill 2020 年 6 月 18 日
use break instead. You should never try to change the loop variable.
break;
  1 件のコメント
Jonathan Babitsch
Jonathan Babitsch 2020 年 6 月 18 日
Thanks a lot David!!
I´m new to matlab and never heard of this command... Works great!
As I said big thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by