The problem is not that the field z of x.y is empty. The problem is that the field y of x is. In the example below, due to the behavior of the struct constructor when one of the values of the fields is a cell array, x.y is a 0-by-0 struct array.
x.y = struct('z', {});
size(x.y)
When S is a struct array with a field T, S.T makes what's known as a comma-separated list with one element per element of S. Consider: q.y = struct('z', 1);
{q.y.z}
w.y = struct('z', {2, 3:4});
{w.y.z}
As that documentation page states, when you create a comma-separated list you can pass it into a function as the input arguments, one input per element in the comma-separated list.
So when the struct from which you create the comma-separated list is empty, as it is if I were to create one from x.y, that's like calling the function with no inputs.
isempty requires you to call it with an input.
Check that x.y has some data (is not empty, or better yet isscalar) before you start asking questions about its data.
Best Answer