Setting mixed table data as empty

조회 수: 6 (최근 30일)
Callum Clarke
Callum Clarke 2016년 7월 18일
답변: Peter Perkins 2016년 8월 3일
I have a table of mixed data, strings and doubles, and I need the ability to set particular entries as empty. Now as each column is of a different data type I can only imagine I must make a big clunky conditional to check the datatype of the column and find out the relevant empty value to set (NaN, '', etc.). Is there an easier way I've missed here? It feels like something that should be easy to do. I have come across standardizeMissing() but it doesn't seem to like wildcards or regex.

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 7월 18일
편집: Azzi Abdelmalek 2016년 7월 18일
% -----------Example-------------------
y={1 2 '3';4 [] 'r';7 5 'ee' ; 4 [] '8'}
a=cell2table(y)
%--------------The code---------------------
b=table2cell(a)
b(cellfun(@isempty,b))={nan}
y=cell2table(b)

Peter Perkins
Peter Perkins 2016년 8월 3일
Callum, it's possible that passing things like isnumeric into varfun as the 'InputVariables' parameter would help, although I'm not entirely sure what you mean by "particular entries".

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by