Stuart’s MATLAB Videos

Watch and Learn

Vectorizing code in MATLAB

When you vectorize code, you avoid looping through an array and instead do operations on the matrix level. This avoids for loops in MATLAB. The reason for vectorizing are often stylistic. Vectorizing is preferred because it can make your code shorter, easier to read and maintain. This simple example contrasts for loop and vectorized implementations of the same algorithm.
  • print
  • send email


To leave a comment, please click here to sign in to your MathWorks Account or create a new one.