How can I remove zeroes column from matrix without removing NaN column?

Hi All,
I have matrix contains zeroes columns and NaN columns and numbers columns, I want to remove [JUST zeroes columns] without removing NaN columns,
Thanks in advance,
Riyadh

 Accepted Answer

matrix(:,~any(matrix==0,1))
% or
matrix(:,any(matrix==0,1))=[]

7 Comments

This expression removes also the culomns that have partial (some) zeroes that I don't want, I want to remove only the columns with all zeroes,
Thanks
man ! give an example and your desired output
It works perfectly without ~ ; matrix(:,all(matrix==0))
Thanks a lot,

Sign in to comment.

More Answers (0)

Categories

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!