Previously we discussed, How to create a FUNCTION in MATLAB. Now in Post 7 of Module 1, we will discuss, how to apply 'for loop' in MATLAB.

For this we are taking example of table. Screen capture of this matlab program is shown in figure.1.

Figure.1 - matlab program for 'For Loop' in MATLAB.

This program consists of 7 lines of code which has been discussed below:

Line-04 : Create a function named as 'mod0107' having single variable.
Line-05 : Display a matter written in single quote (' '), with value of variable at %d.
Line-06 : Start a 'for loop' from 1 to 10.
Line-07 : Perform Mathematical operation.
Line-08 : Display a matter written in single quote (' '), with value of all three variables at location %d.
Line-09 : End of for loop.
Line-10 : End of function.

To execute this function, Type the name of function in command window with value of variable in bracket. The screen capture of the command window is shown in figure.2.

Figure.2 - Result taken from 'For loop' in MATLAB function.

The For Loop in MATLAB function has been executed for the variable 19.

Video Tutorial : How To Apply FOR Loop in MATLAB By INFO4EEE


  1. […] we discussed, How to apply ‘For Loop’ in MATLAB. Now in Post-8 of Module-1, we will discuss, how to apply ‘double for loop’ in […]

  2. […] Read Post-07 of Module-I: How to apply FOR LOOP in MATLAB. […]


Thanks for Your Faith on INFO4EEE!!!

Powered by Blogger.