MATLAB: Removing columns containing zeros

matrixremove columnsremove zeros

I have a 2×500 matrix containing data. Some columns contain only zeros and I need to remove these (forming, say, a 2×460 matrix when 40 columns contained zeros).
Similar questions have been asked and answered about cell arrays which give commands such as:
m = m(cellfun(@ischar,m(:,1)),:);
These commands produce the error 'Input #2 expected to be a cell array, was double instead' when I use my matrix in place of 'm'

Best Answer

m=m(:,any(m))
Best wishes
Torsten.