You can actually check this out by timing something like taking the sine of a variable for 100 different values of the variable. The logical way to do it in matlab is to create a vector of those 100 different values, and take the sine of that vector. If you do it instead by a for loop from 1 to 100:
b = [some vector of 100 elements] for n = 1:100, a(i) = sin(b(i)); endit will take much longer. Sometimes you can't avoid using loops, but if you write your matlab scripts cleverly, you can make them much more efficient. Using logical conditions to select parts of your matrices (as we discussed in Lecture 1) is one way that is easy to take advantage of in vectorizing your problems.