MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Asked by C Zeng
on 30 May 2013

Hi, all,

I recently found that Matlab executes matrix/vector computation pretty fast than scalar computation with loops. For example, if I used loops to execute algorithm, it is very slow. If I convert it to vector or matrix, it is faster.

I was told about this fact before, is there any explanation on it?

The bad thing is that you cannot always use matrix to replace loops...

Thanks.

*No products are associated with this question.*

Answer by Jonathan Sullivan
on 30 May 2013

Accepted answer

This has some good information on the topic:

http://www.mathworks.com/help/matlab/matlab_prog/vectorization.html

## 0 Comments