Introduction to vectorizing in MATLAB - any good tutorials?

Posted by Gacek on Stack Overflow See other posts from Stack Overflow or by Gacek
Published on 2010-05-19T17:28:33Z Indexed on 2010/05/19 17:30 UTC
Read the original article Hit count: 253

Filed under:
|
|
|

I'm looking for any good tutorials on vectorizing (loops) in MATLAB.

I have quite simple algorithm, but it uses two for loops. I know that it should be simple to vectorize it and I would like to learn how to do it instead of asking you for the solution.

But to let you know what problem I have, so you would be able to suggest best tutorials that are showing how to solve similar problems, here's the outline of my problem:

B = zeros(size(A));    % //A is a given matrix.
for i=1:size(A,1)
   for j=1:size(A,2)
      H = ... %// take some surrounding elements of the element at position (i,j) (i.e. using mask 3x3 elements)
      B(i,j) = computeSth(H); %// compute something on selected elements and place it in B
   end
end

So, I'm NOT asking for the solution. I'm asking for a good tutorials, examples of vectorizing loops in MATLAB. I would like to learn how to do it and do it on my own.

© Stack Overflow or respective owner

Related posts about matlab

Related posts about vectorizing