I have a struct x, with dynamic Fields, respectively dynamic Field names. But basically, only the first Field is relevant for me. So I want to check if the Value of the first Field is empty, speak a 1x1cell or a 0x1cell..
or
I'm experimenting e.g. with:
isempty(fieldnames(x))
isempty(x(1))
if isempty(x(1))
msgbox('empty')
else
msgbox('result')
end
but got to no solution. Does anybody have a clue?
Speak, check if the Value of the first Field of the struct is empty or not..
If only the first field is relevant to you, then you can proceed as follows :
names=fieldnames(x);
SizeOfFirstField=size(x.(names{1}));
Then you can just check if the first value in SizeOfFirstField
is 0 or 1 in your if
condition :
if SizeOfFirstField(1)==0
msgbox('empty')
else
msgbox('result')
end