MATLAB Answers

C Zeng

compare loops and matrix computation.

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.

  0 Comments

Products

No products are associated with this question.

1 Answer

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

  1 Comment

C Zeng
on 30 May 2013

Thanks, Jonathan!


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today