function B = rotate180(A) [m,n] = size(A); B = zeros(m,n); for i=1:m for j=1:n B(i,j) = A(m + 1 - i,n + 1 - j); end end