Finding which rows in table contain NaN, save those as new table
조회 수: 49 (최근 30일)
이전 댓글 표시
Im looking to find a way to figure our which rows contain a 'NaN' in column 5, and then save all of those that do as a new table
채택된 답변
Guillaume
2020년 2월 6일
Assuming your input is a table:
nantable = yourtable(isnan(yourtable{:, 5}), :) %keep all rows whose 5th column is nan
댓글 수: 0
추가 답변 (1개)
Adam Danz
2020년 2월 6일
편집: Adam Danz
2020년 2월 7일
If the tables all contain the same variable names (headers), use the variable names to index columns rather than column number. This is one of the strengths of tables over matrices and cell arrays. If the variable names are different, then you'll have to use numeric indexing.
Suppose column 5 is named "MyData" and the table is named "T".
nanIdx = isnan(T.MyData);
% If you must use numeric indexing,
% nanIdx = isnan(T{:,5});
Create the new table
Tnew = T(nanIdx,:);
참고 항목
카테고리
Help Center 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!