Remove missing from cell array

조회 수: 12 (최근 30일)
Gian Pietro Luca
Gian Pietro Luca 2019년 5월 30일
댓글: Andreas Martin 2020년 7월 14일
I have used readcell to read tabular data.
How can the missing elements be removed?
6×1 cell array
{'a' }
{'b' }
{'c' }
{'d' }
{1×1 missing}
{1×1 missing}
  댓글 수: 2
Gian Pietro Luca
Gian Pietro Luca 2019년 5월 30일
But how? I tried the obvious rmmissing(cellarray) and it fails with:
Error using matlab.internal.math.ismissingKernel/arraySwitch (line 79)
First argument must be numeric, logical, datetime, duration, calendarDuration, string, categorical, char, cellstr, table,
or timetable.

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

답변 (1개)

madhan ravi
madhan ravi 2019년 5월 30일
yourcell(cellfun(@ischar,C))
  댓글 수: 3
Gian Pietro Luca
Gian Pietro Luca 2019년 5월 30일
Thanks. It is helpful and seems to work but, is it the "standard" way to deal with missing parameters? It seems a bit overbloated: A=A(cellfun(@ischar,A)). Also, if I have a mixture of numbers and strings, it might not work, right?
Andreas Martin
Andreas Martin 2020년 7월 14일
Yes, in that case it doesn't work. Try then this instead:
C( cellfun( @(c) isa(c,'missing'), C ) ) = {[]};

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by