Showing posts with label matlab for. Show all posts
Showing posts with label matlab for. Show all posts

Monday, August 19, 2013

Loops in Matlab ( for in matlab, while matlab, for matlab)

There are two loops in matlab:
  • For loops 
  • While loops
For loops are used when the number of loop is certain whereas while loops are used when the condition is specified for a loop to terminate the code in it. 

You can see the usage form of for loops and while loops from given examples below:

Example 1: For loop



Example 2: While loop



For information in detail type in command window:

'help for' to get the following result:



or you can type doc for  to get reference page in help browser. I am not giving it here.

For while loops you can type:

'help while' to get information in detail like as given below:



or you can type 'doc while'  to get reference page in help browser. I am not giving it here.

If you have any question or need some help, leave a comment below.

Read More