MATLAB: Delete zeros rows and columns

arraydeleteMATLABmatrixzeros

I try this code to delete all row and column with all zero values in them. It simply works for deleting the columns with all zero values abut it does not work for rows! Can anybody please help me?
data=[0 0 0 0 0 0 0 0; 0 0 2 3 4 0 1 0; 0 0 1 2 3 0 0 0];
data( all( ~any( data), 2 ), : ) = []; % removes all rows with all zero
data( :, all( ~any( data ), 1 ) ) = []; % and columns
I mean the first line (% removes all rows with all zero) does not work!

Best Answer

data( ~any(data,2), : ) = []; %rows
data( :, ~any(data,1) ) = []; %columns