Check if the value for a field in a struct exists
Show older comments
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.
Accepted Answer
More Answers (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)
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!