If you look at the whos documentation .
You can do it:
variableStruct = whos('x');
nbByte = variableStruct.bytes
If the variable does not exist, your structure is empty.
EDIT
With subref you can do this in one liner as follows:
byte = subsref(whos('x'),struct('type','.','subs','bytes'));
Vuwox source
share