フィルターのクリア

Removing entire column if any of the value in that column contains a NaN

1 回表示 (過去 30 日間)
Wietze Zijpp
Wietze Zijpp 2022 年 4 月 4 日
回答済み: Voss 2022 年 4 月 4 日
I am trying to clean up my dataset. Therfore I want to remove any columns that contain any Nan values.
The dataset is of form table. I have tried a few approaches but did not succeed

採用された回答

Voss
Voss 2022 年 4 月 4 日
% make a table with some NaNs:
A = magic(5);
A([7 15]) = NaN;
t = array2table(A)
t = 5×5 table
A1 A2 A3 A4 A5 __ ___ ___ __ __ 17 24 1 8 15 23 NaN 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 NaN 2 9
% remove columns/table-variables with any NaNs:
t(:,any(isnan(t{:,:}),1)) = []
t = 5×3 table
A1 A4 A5 __ __ __ 17 8 15 23 14 16 4 20 22 10 21 3 11 2 9

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by