To determine how many times a loop will execute in Matlab, you need to know the initial value of the loop control variable, the final value of the loop control variable and the amount by which the loop control variable is incremented or decremented during each iteration of the loop. You can then use this information to determine the number of times the loop will execute using the following equation:
main.m70 chars2 lines
Here is an example loop that counts from 1 to 10 in increments of 1:
main.m29 chars4 lines
The number of loop iterations in this case is:
main.m17 chars2 lines
So the loop will execute 9 times.
gistlibby LogSnag