MATLAB: While loop with a boolean expression

while loop

why my boolean expression is not working , is there any syntax error. here is my code :
v=false;
while ((i < N)&&(v==false)) if (condition) v=true; i=i+1; else i=i+1; end end

Best Answer

Don't even use v. Just break:
while (i < N)
if (condition)
break;
end
i=i+1;
end
Related Question