Remove missing from cell array

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 件のコメント

Stephen23
Stephen23 2019 年 5 月 30 日
編集済み: Stephen23 2019 年 5 月 30 日
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 日

0 投票

yourcell(cellfun(@ischar,C))

3 件のコメント

madhan ravi
madhan ravi 2019 年 5 月 30 日
編集済み: madhan ravi 2019 年 5 月 30 日
Read this once again
Try the above see if it satisfies your need else show what missing data contains
since I don’t know because I’m not at the latest stand.
Use 'isempty' instead of @ischar if missing contains an empty scalar.
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 ) ) = {[]};

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCell Arrays についてさらに検索

質問済み:

2019 年 5 月 30 日

コメント済み:

2020 年 7 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by