Adjusting For loop size

1 回表示 (過去 30 日間)
Jared
Jared 2013 年 2 月 13 日
If I am doing something like:
for i=1:length(array)
if length(array(i)) < 10
array(i)=[];
i=i-1;
end
end
When I delete that index, the array is no longer the same length as the for loop, so I am getting an index exceeds matrix dimensions error. How can I adjust the length of the for loop?

採用された回答

Jason Ross
Jason Ross 2013 年 2 月 13 日
I think you are looking for a while loop rather than a for loop.
  1 件のコメント
Jared
Jared 2013 年 2 月 13 日
You're right, forgot about them. It's too early...

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by