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

Control Structures (while statement loop)

Among the control structures in programming languages, 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'
 
Top

Switch Statement

For - Statement

If - Statement





footer for control structures (while-statement) page