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 CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by