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

Control Structures (while statement loop)

Among the control structures, there is the while... end loop which repeats a group of statements an indefinite number of times under control of a logical condition.

Syntax:
while expression
    statements
    ...
end

Example:



counter = 100;

while (counter > 95)
   disp ('counter is still > 95')
   counter = counter -1;
end
disp('counter is no longer > 95')



Matlab response is:

counter is still > 95
counter is still > 95
counter is still > 95
counter is still > 95
counter is still > 95
counter is no longer > 95
>>


The cautions involving matrix comparisons that are discussed in the section on the if statement also apply to the while statement.


From 'control structures' to home
From 'control structures' to 'Matlab Control Flow'


footer for control structures (while-statement) page