MATLAB: How to change an entire column.

matrix array

Hi,
I have a matrix with a dimension of 10×640. The matrix is filled with ones and zeros. If there is a zero in one of columns, I want the entire column to be zeros. How can I do this?
Example:
[[1,0,1];[1,1,1]]
Output should be:
[[1,0,1];[1,0,1]]

Best Answer

A = randi(10,[10 640])-1;
B = A;
B(:,sum(A==0)>0)=0;