From: Eamonn B on
I have a matrix with points and I have a for loop that will go through each of these points and if a condition is met it will delete one of the points from the list. But I want to reset the loop once it has deleted a few points as I get an error once my incrementing variable get too high for my formula.

I have it so that once it reaches a point I want to reset n (my incrementing variable)
t=mArrayLength-length(a);
if t==-1
n=0
prevPoints(:)=[];
end

That is what I currently have but it doesnt seem to go through the the for loop again.
From: nickchng on
If I understand you, perhaps a while loop is more appropriate if your loop is of an unknown length. The pseudocode would be:

counter = 1;
while list_not_too_long
__check matrix
__if deletion necessary
____delete point
____check #deletions
____if #deletions too large
______counter = 1;
____else
______counter = counter +1;
____end
__end
end
From: Steven Lord on

"Eamonn B" <pakblue11(a)gmail.com> wrote in message
news:hpaaee$mp5$1(a)fred.mathworks.com...
>I have a matrix with points and I have a for loop that will go through each
>of these points and if a condition is met it will delete one of the points
>from the list. But I want to reset the loop once it has deleted a few
>points as I get an error once my incrementing variable get too high for my
>formula.
>
> I have it so that once it reaches a point I want to reset n (my
> incrementing variable)
> t=mArrayLength-length(a);
> if t==-1
> n=0
> prevPoints(:)=[];
> end
>
> That is what I currently have but it doesnt seem to go through the the for
> loop again.

Don't delete the points inside the loop. Create a logical array the same
size as the array from which you're deleting and set the appropriate element
of that array if it meets your deletion criteria, then delete all the marked
elements after the loop is complete.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ