break語句用來終止for或while迴圈的執行。 在迴圈中break語句之後出現的語句不執行。
在嵌套迴圈中,break僅從它所在的迴圈中退出。控制傳遞到該迴圈結束後的語句。
流程圖

例子
創建腳本檔並鍵入以下代碼:
a = 10;
% while loop execution
while (a < 20 )
   fprintf('value of a: %d\n', a);
   a = a+1;
      if( a > 15)
         % terminate the loop using break statement
         break;
      end
end
執行上面示例代碼,得到以下輸出結果 -
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
