MATLAB: Create new matrix by deleting columns with negative numbers from old matrix

creatematrix

I'm stuck with this problem where i need to create a matrix M from matrix A(5×5) by deleting columns from A that contain a negative number. Using loops is unfortunately forbidden. Any help is greatly appreciated.

Best Answer

M = A(:,all(A>=0,1));