ENGRMAE 10 Lecture Notes - Lecture 6: Hayes Command Set, United States Equestrian Federation, Iterator
Document Summary
Loops are useful when you want a certain set of commands executed over and over and over and over and . There are two types of loops in matlab/octave: (a) for loops and (b) while loops. (a) for loops: For loops are useful when you know you need to perform a task a certain amount of times. for index = a:c:b commands end. The index variable will take on all the values in the array a:c:b as it goes through the loop. The first value of index will be a. Often, it is useful to think of a, c, and b in the following terms, for index = initial value : increment : end value commands end. Let"s say the a is 1, c is 2, b is 5. 1:2:7 yields an array of 1 3 5 7. When the for loop begins, the first value of index will be the first array element, 1.