%Script file to compare "break" to "continue" % (Break terminates the "for" loop) for g=1:5 g if g<3 if g==2 fprintf('If statement 1 is over\n'); break else fprintf('If statement 2 is over\n'); break end fprintf('If statement not triggered\n'); else fprintf('Big else is triggered\n'); break end fprintf('End of if-then\n'); end fprintf('Outside of for loop\n'); fprintf('\n\n New Loop.............................................\n'); %Compare that output with the output from this code: for g=1:5 g if g<3 if g==2 fprintf('If statement 1 is over\n'); continue else fprintf('If statement 2 is over\n'); continue end fprintf('If statement not triggered\n'); else fprintf('Big else is triggered\n'); continue end fprintf('End of if-then\n'); end fprintf('Outside of for loop\n');