Nested for loops, MATLAB in Statistics

Nested for Loops:

The action of a loop can be any of the valid statement(s). Whenever the action of a loop is the other loop, this is known as nested loop.

As an illustration, a nested for loop will be elaborated in a script which will print a box of *'s. The variables in the script will identify how many rows and columns to print. For illustration, if rows have the value 3, and columns have the value 5, the output would be:

 

*****

*****

*****

 

As the lines of output are controlled by printing the newline character, the fundamental algorithm is:

For every row of output,

- Print the needed number of *'s

- Shift the cursor down to the next line (print the '\n')

985_Nested for Loops.png

2185_Nested for Loops1.png

 

Posted Date: 10/19/2012 3:46:25 AM | Location : United States







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

Write discussion on Nested for loops
Your posts are moderated
Related Questions
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

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

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

Rectangle - graphics objects: The other core graphics object is the rectangle that can have curvature added to it (!!). Merely calling the function rectangle without any argum

Example of customizing plots: As the other illustration of customizing plots, the pieces of a pie chart can be "exploded" from the rest. In this situation, the two vectors are

Illustration of Input in a for loop: In this illustration, the loop variable iv iterates through the values 1 through 3, therefore the action is repeated three times. The acti

Variable packages: Variable packages are now the vector of structures, hence each and every element in the vector is a structure. To show one element in the vector, an index i

Run-time or execution-time error: The Run-time, or execution-time, errors are found whenever a script or function is executing. With most of the languages, an illustration of

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

Help function: Function is computing the two values, there are two output arguments in the function header (i.e., area & circum), that are placed in the square brackets [ ]. A