Check if the value for a field in a struct exists
Ältere Kommentare anzeigen
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.
Akzeptierte Antwort
Weitere Antworten (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)
Kategorien
Mehr zu Structures finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!