Is there a way to see how many bits make up an arbitrary variable X in MATLAB?

I have an arbitrary variable X, and I would like to apply the function and get the number of bits of X as output. I know that I can use "whos", but I want a useful output of the number of bits of X.

Is there any (built-in) function that can do this in MATLAB?

+4
source share
1 answer

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'));
+7
source

All Articles