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

 Risposta accettata

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

7 Commenti

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
matrix(:,~all(matrix==0))
man ! give an example and your desired output
It works perfectly without ~ ; matrix(:,all(matrix==0))
Thanks a lot,

Accedi per commentare.

Più risposte (0)

Categorie

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by