MATLAB: Advanced logical matrix indexing

logial indexing matrix

Is it possible to use one line of code to achieve the following
given an NxN matrix A construct an N-1xN matrix B where each column _n in B eliminates the _nth element from the _n column in A
e.g.
A = [1 1 1;2 2 2;3 3 3] gives B = [2 1 1;3 3 2]
I can do this in a for-loop, but given MATLAB is really bad at handling these I was hoping there is a faster solution
Thanks,
~K

Best Answer

Another variation of Matt J's approach:
B = A(:);
B(1:(N+1):(N*N)) = [];
B = reshape(B,N-1,N);