Remove missing from cell array

14 vues (au cours des 30 derniers jours)
Gian Pietro Luca
Gian Pietro Luca le 30 Mai 2019
Commenté : Andreas Martin le 14 Juil 2020
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 commentaires
Stephen23
Stephen23 le 30 Mai 2019
Modifié(e) : Stephen23 le 30 Mai 2019
Gian Pietro Luca
Gian Pietro Luca le 30 Mai 2019
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.

Connectez-vous pour commenter.

Réponses (1)

madhan ravi
madhan ravi le 30 Mai 2019
yourcell(cellfun(@ischar,C))
  3 commentaires
Gian Pietro Luca
Gian Pietro Luca le 30 Mai 2019
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 le 14 Juil 2020
Yes, in that case it doesn't work. Try then this instead:
C( cellfun( @(c) isa(c,'missing'), C ) ) = {[]};

Connectez-vous pour commenter.

Catégories

En savoir plus sur Cell Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by