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

action

end

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
Use of function polyval: The better the curve fit, the more exact these interpolated and extrapolated values will be. By using the subplot function, we can loop to display the

Graphics objects: The objects involve graphics primitives like lines and text, and also the axes used to orient the objects. These objects are organized hierarchically, and the

Functions which complete a task without returning Values: Most of the functions do not compute values, but instead of accomplish a task like printing formatted output. As thes

Indexing: The Indexing is an alternate to sort a vector. With indexing, the vector is left in its original order. An index vector is used to point values in the original vecto

Areacirc function: The areacirc function can be called from the Command Window as shown here, or from a script. Here is a script which will prompt the user for the radius of o

Illustration of Indexing: Though, rather than of creating the index vector manually as shown here, the process to initialize the index vector is use to a sort function. The al

Logical errors: The Logical errors are more complicated to locate, as they do not result in any error message. The logical error is a mistake in reasoning by the programmer, b

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

The IF Statement: The if statement selects whether or not the other statement, or group of statements, is executed. The common form of the if statement is as shown below: i

Functions which return Values versus printing: Also, the function which computes and returns values (throughout the output arguments) does not generally print them; that is le