Check if the value for a field in a struct exists
Afficher commentaires plus anciens
A struct can have a field name with no value. For example:
A=struct('a',{})
How can I check if this is the case?
I tried
isempty(A.a)
But an error says not enough input arguments.
Réponse acceptée
Plus de réponses (1)
Watch your struct() syntax,
A=struct('a',[]) %field 'a' with empty matrix
isempty(A.a)
B=struct('a',{{}}) %field 'a' with empty cell array
isempty(B.a)
Catégories
En savoir plus sur Structures dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!