MATLAB: Is it available to change the end of a loop for inside it

endvalfor loopMATLAB

ssss.PNG
ssssss.PNG
the size of my variable out changes inside the loop for so that's why I recalculate it inside it but the loop variable i stops in the first size of the variable even sizeOut changes.
can't the endval of the loop change ? or it can't ?

Best Answer

You want to use a while loop for this purpose.
It might look something like this (tough to tell without seeing more of your code)
c = 2; %counter
while c <= sizeOut(1,1)
% Do something
c = c+1;
end
Another good suggestion by Stephen Cobeldick is to add a conditional break to the for-loop that exits the loop when the sizeOut variable reaches a certain size.