Getting Started |
Vectorization
To obtain the most speed out of MATLAB, it's important to vectorize the algorithms in your M-files. Where other programming languages might use for
or DO
loops, MATLAB can use vector or matrix operations. A simple example involves creating a table of logarithms.
A vectorized version of the same code is
For more complicated code, vectorization options are not always so obvious. When speed is important, however, you should always look for ways to vectorize your algorithms.
The eval Function | Preallocation |