« Earlier2 items total Later »

Vectorize operations based on column and row indicies

Vectorize this
for i = 1:100
  for j = 1:100
    r(i,j) = sqrt(i^2+j^2);
  end
end


becomes

[i,j]=meshgrid(1:100,1:100);
r = sqrt(i.^2+j.^2);

Reverse one column or row of a matrix

To reverse column or row c of a Matrix M
M(:,c)=flipud(M(:,c))


M(c,:)=flipud(M(c,:))

« Earlier2 items total Later »




Sponsored by

Sole Central

Your one stop shop for Birkenstock and Crocs shoes and sandles.