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
Matrixmania Blog
Contact
-> Sitemap <-
Matlab Books
Quick Matlab Guide
Matlab Tutorials
Matlab Examples
Matlab Flow Control
Boolean Algebra
Linear Algebra
Matlab 2D Plots
Matlab 3D Plots
Matlab GUI
Matlab Cookbook I
Matlab Cookbook II
Probability and Stats
Forums and Help
Relevant Links
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'


footer for matlab page