Stuart’s MATLAB Videos

Watch and Learn

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Vectorizing code in MATLAB

Posted by Doug Hull,

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.

Add A Comment

Your email address will not be published. Required fields are marked *

Preview: hide