MATLAB: Exit code from program

terminate

What is the code that terminates the program and stop it?

Best Answer

Try this:
again = true; % Flag for iterating the outer while loop again.
loopCounter1 = 1; % Count iterations to prevent infinite loop. This is a "fail safe".

loopCounter2 = 1; % Count iterations to prevent infinite loop. This is a "fail safe".
maxIterations = 9999; % Whatever is the most you ever expect.
while condition1 && again && loopCounter1 < maxIterations
while condition2 && loopCounter2 < maxIterations
if condition3
% statements
% increment counter
break; % Breaks out of inner while loop only, loop #2.
else
% Here i want to break out without return to any while
again = false; % Make sure outer while loop does not iterate again.
break;
end
% Increment counter

loopCounter2 = loopCounter2 + 1;
end
% Increment counter
loopCounter1 = loopCounter1 + 1;
end