While loops, MATLAB in Statistics

WHILE Loops:

The while statement is used as a conditional loop in MATLAB; it is used to repeat an action whenever ahead of the time it is not known how many times the action will be repeated. The common form of the while statement is as shown below:

while condition



The action that consists of any number of statements is executed as long as the condition is true. The condition should eventually become false to avoid an infinite loop. (If this occurs, Ctrl-C will exit the loop.)

The way it works is that, at first the condition is computed. If it is logically true, the action is executed. Therefore, to start with it is merely like an if statement. Though, at that point the condition is computed again. If it is still true, the action is executed once again. Then, the action is computed again. If it is still true, the action is executed again. Then, the action is... ultimately, this has to stop! Ultimately something in the action has to change something in the condition so it becomes false.



Posted Date: 10/19/2012 6:02:28 AM | Location : United States

Related Discussions:- While loops, Assignment Help, Ask Question on While loops, Get Answer, Expert's Help, While loops Discussions

Write discussion on While loops
Your posts are moderated
Related Questions
#qYou will need to examine two of the nine sections of data: one section of qualitative data (choose either Gender or Position) one section of quantitative data (choose either Intr

Polynomials: Simple curves are polynomials of various degrees, or orders. The degree is the integer of the highest exponent in the expression. The illustrations are as follows

function sortrows - sorting strings: The function sortrows sorts each and every row as a block, or group, and it also will work on numbers. Here in this illustration the rows

Roots function - Polynomials: The roots function in MATLAB is used to find the roots of an equation represented by a polynomial. For illustration, for the mathematical functio

Illustration of Binary search: An illustration to search for the key of 91 in the vector is as shown below: The table below shows what will happen in each iteration of

Example of Nested functions: For illustration, the function below computes and returns the volume of a cube. Three arguments are then passed to it, for the width and length of

Working of Editor and debugger: Editor/Debugger, or commands can be typed from Command Window. For illustration, the dbstop command below will set a breakpoint in the fifth li

Illustration of Indexing into vectors of structures: For illustration, the function to print the information from packages has been modified therefore in addition to the vecto

Debugging Techniques: Any error in the computer program is called a bug. This word is thought to date back to the 1940s, whenever a problem with an early computer was found to

Input in a While Loop: The script below repeats the procedure of prompting a user, the reading in a positive number, and echo-printing it, as long as the user properly enters