フィルターのクリア

How do I change the iteration variable of the for loop?

4 ビュー (過去 30 日間)
Ottavia Rossini
Ottavia Rossini 2017 年 4 月 5 日
コメント済み: Ottavia Rossini 2017 年 4 月 5 日
Is there any way to change the iteration of the forlooplimit in the code? I tried this:
for j = 1:a-b
plot(Position(1, j), Position(2, j), 'r.');
if (Position(1, j) >= 50)
Position(1,j)=[];
b=b+1;
end;
end;
but it's not working since my Positionmatrix changes size and the index j get's out of bound.

回答 (1 件)

Thorsten
Thorsten 2017 年 4 月 5 日
編集済み: Thorsten 2017 年 4 月 5 日
It's not possible. Use a while loop instead:
j = 1;
while j < = a - b
plot(Position(1, j), Position(2, j), 'r.');
if Position(1, j) >= 50
b = b + 1;
end
j = j + 1;
end
  1 件のコメント
Ottavia Rossini
Ottavia Rossini 2017 年 4 月 5 日
ok thanks! i'll try that :)

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

カテゴリ

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