i want to delete a specific number of NaN in a matrix

1 回表示 (過去 30 日間)
Marco Callado
Marco Callado 2019 年 2 月 13 日
コメント済み: Marco Callado 2019 年 2 月 13 日
i have a matrix A, and i would like to delete the columns with all cells NaN and the ones with just one valid number
A =
1 3 5 1 NaN
2 3 4 NaN NaN
NaN 4 2 NaN NaN
NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN
and i manage to delete some with
A(:,all(isnan(A)))=[] %to al column with all cells as NaN
A(:,any(isnan(A)))=[] %to whatever nan i find

採用された回答

madhan ravi
madhan ravi 2019 年 2 月 13 日
A(:,all(isnan(A)))=[]; % delete columns with only NaNs
A(:,sum(~isnan(A))==1)=[] % deletes column filled with one number
  1 件のコメント
Marco Callado
Marco Callado 2019 年 2 月 13 日
It was really helpful
Thank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by