extract column name of table with Nan column

조회 수: 11 (최근 30일)
joms
joms 2019년 5월 17일
답변: Peter Perkins 2019년 5월 20일
How can i return the label name of column with values all Nan
sample1=[1 2 3]';%Sample data
sample2=[4 5 6]';%Sample data
sample3=[7 8 9]';%Sample data
sample4=nan(3,1);%Sample data
patients = table(sample4,sample2,sample3)
sample4 sample2 sample3
_______ _______ _______
NaN 4 7
NaN 5 8
NaN Nan 9
output should be 'sample4' as cell array
NanLabels={'sample4'}

채택된 답변

madhan ravi
madhan ravi 2019년 5월 17일
patients.Properties.VariableNames(all(isnan(patients{:,:})))
  댓글 수: 1
joms
joms 2019년 5월 17일
Thank you very much madhan ravi! This is exactly im looking for.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Peter Perkins
Peter Perkins 2019년 5월 20일
Using {:,:} to convert the entire table to a homogeneous array is perhaps one way to do this, but scales badly very quickly as the table gets big.
allMissing = all(ismissing(patients),1)
gives you a logical vector of variables in the table all of whose values are missing (whether or not they are numeric). Use that as a subscript into patients.Properties.VariableNames.

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

제품


릴리스

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by