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
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

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

Location of a rectangle - graphics objects: The location of a rectangle is [x y w h], where x and y are the coordinates of the lower left point, here w is the width, and h is

Operation on file: We concentrate first on the fgetl function that reads strings from the file one line at a time. The fgetl functions afford more control over how the data is

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

Reading from Files: There are many lower level functions which read from files. The function fscanf reads the formatted data into a matrix, by using conversion formats like %s

Example of Function stubs: The three functions have not so far been written, though, therefore the function stubs are put in place so that the script can be executed and teste

Function Stubs: The other common debugging method, which is used when there is a script main program which calls many functions, is to use the function stubs. A function stub

Steps for input output functions - Lower level file: The steps involved are as shown below:  Open the file.  Read the file, write to the file, or append to the file.

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