logo for matrixlab-examples.com
[?] Subscribe To This Site

XML RSS
Add to Google
Add to My Yahoo!
Add to My MSN
Subscribe with Bloglines


Home
Welcome Matrixmania Blog
-> Sitemap / Search <-
-> Books <-
Forums and Help
Contact
Basics Quick Matlab Guide
Matlab Tutorial
Matlab Examples
Matlab Flow Control
Boolean Logic
Plots and GUI Matlab 2D Plots
Matlab 3D Plots
Matlab GUI
Applications Calculus
Linear Algebra
Matlab Cookbook I
Matlab Cookbook II
Electrical Calculations
Probability and Stats
Finance Apps
Other Relevant Links
Notes on Computing
Online Calculators
Fun!
Your own Website?
Terms/Policies
leftimage for matrixlab-examples.com

' break ' statement


The break statement lets you exit early from a for or while loop. In nested
loops, break exits from the innermost loop only.




Example 1:

for i = length(x)
   % check for positive y
   if y(x) > 0
      % terminate loop execution
      break
   end
   % follow your code
   a = a + y(x);
   ...
end



Example 2:

x = sin(sqrt(variable));
while 1
   n = input('Enter number of loops: ')
   if n <= 0
      % terminate loop execution
      break
   end
   for i = 1 : n
      % follow your code
      x = x + 20;
      ...
   end
end




 From 'break statement' to home

 From 'break statement' to 'Matlab Code - Flow Control'

Top



footer for matlab page