Effacer les filtres
Effacer les filtres

How to check whether a specific variable is empty or not in table type

15 vues (au cours des 30 derniers jours)
Sangmin Lee
Sangmin Lee le 17 Avr 2020
Commenté : Sangmin Lee le 17 Avr 2020
Hi, please see the follwing figure.
As you can see, in this 'table' type variable, some rows does not have 'ls_max_tone' and some have 'ls_max_tone' .
'ls_max_tone' variable is defined as 'cell' type.
I can find which row has 'ls_max_tone' variable using for loop. However, I know this is not efficient way.
Is there any efficient way such as
T_data(T_data.temperature >50, :)
which returns all rows that temperature value exceeds 50.
Thanks in advance.

Réponse acceptée

Tommy
Tommy le 17 Avr 2020
T_data(~cellfun(@isempty, T.ls_max_tone),:)
This will return a table containing only the rows where ls_max_tone is not empty.
  1 commentaire
Sangmin Lee
Sangmin Lee le 17 Avr 2020
Thanks a lot!
I am always having difficulty in using cell array and cell function (@).
It works!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical 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