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
Generic code for Reading from Files: The generic code to complete this is as shown below:   fid = fopen('filename'); if fid == -1    disp('File open not suc

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

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

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

Advanced File Input and Output: In that section, we saw how to read the values entered by user using the input as well as the output functions disp and fprintf, that shows inf

Mode The mode of a data set is the value which appears most often. The built-in function in a MATLAB for this is known as the mode. >> x = [9 10 10 9 8 7 3 10 9 8 5 10];

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

Core Objects: The Core Objects in MATLAB are the very fundamental graphics primitives. The description can be found under the MATLAB Help: Under the Contents tab, click the Ha

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

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