The syntax of for loop in MATLAB is:
main.m46 chars4 lines
Here, loop_variable is the loop counter that takes value from the range in each iteration of the loop. The range can be defined using start:step:end syntax. Using start and step are optional. If step is not defined, it assumes the default value 1.
Here is an example for loop that prints the numbers from 1 to 10 in MATLAB:
main.m29 chars4 lines
This will produce the following output:
main.m21 chars11 lines
You can use the loop variable i inside the loop to perform any operation using the current value of i.
gistlibby LogSnag