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
Nested Structures: The nested structure is a structure in which at least one of the members is itself a structure. For illustration, a structure for the line segment may co

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

Illustration of Nested loops: Running the script shows the output: >> printstars ***** ***** ***** The variable rows identifies the number of rows to print, and

Nested Functions: We have seen that the loops can be nested, that means that one inside of the other, functions can be nested. The terminology for nested functions is that an

Advanced File Input and output: Where 'format' involves the conversion characters much like those used in the fprintf function. For illustration, to read the file 'subjexp.dat

MENU Function: The MATLAB also has a built-in function known as menu which will display a figure Window with push buttons for the choices. The very first string passed to the

Example of Median For the vector [1 4 5 9 12 33], the median is the average of the 5 & 9 in the middle: >> median([1 4 5 9 12 33]) ans =     7

Opening and Closing a File: The Files are opened with the fopen function. By the default, fopen function opens a file for reading. If the other mode is preferred, a permission

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 w

Tracing: Sometimes, when a program has loops and/or selection statements and is not running properly, it is helpful in the debugging process to know exactly which statements h