
268 Accelerating MATLAB
®
Performance
Sometimes we can improve performance by telling MATLAB explicitly how to distrib-
ute work across the multiple processing units (explicit parallelism) — CPU cores, CPUs, and
GPUs. This topic will be covered in Chapters 6 and 7.
5.7 Effective Use of MATLAB Vectorization
5.7.1 Vectorization Is Not Always Faster
Despite a commonly entrenched belief, vectorization is not always faster than the simpler
looped equivalent. We have already seen an example of this in §5.3.6 and §5.3.9, where the
fully vectorized version did not outperform a simple JIT-ted loop. This effect is sometimes
surprising. Consider the follo ...