How to delete the columns that has NaN values?
88 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ashfaq Ahmed
am 17 Aug. 2022
Kommentiert: Ashfaq Ahmed
am 17 Aug. 2022
Hi!
I have this 5x5 matrix. Of them, only column 2 and 3 does not contain any NaN values. How can I write down a code that will delete the entire column which even has only one NaN value?
1 2 3 4 5
NaN 6 7 8 11
4 8 9 1 NaN
NaN 4 0 2 8
NaN 1 6 NaN 9
0 Kommentare
Akzeptierte Antwort
Cris LaPierre
am 17 Aug. 2022
Since column correspond to the second dimension you would do this
A = [1 2 3 4 5
NaN 6 7 8 11
4 8 9 1 NaN
NaN 4 0 2 8
NaN 1 6 NaN 9];
R = rmmissing(A,2)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!