MATLAB: Check if any field in a given structure is empty

structstructures

Hello everyone,
I have a structure with quite some fields and I want to check, if any of the fields are empty. Is there a way to do this without checking for each field individually?
Currently I have an if statement with many ORs to do this:
if isempty(structure.field1) || isempty(structure.field2)
and so on
I tried to do the same with
any(isempty(fieldnames(structure))
but obviously the fieldnames are not empty.

Best Answer

any( structfun(@isempty, YourStructure) )