Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

matlab

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

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

like image 737
Alex Avatar asked Mar 22 '23 08:03

Alex


1 Answers

If you look to whos documentation.

You can do this :

variableStruct = whos('x');

nbByte = variableStruct.bytes

If the variable doesn't exist, you structure is empty.

EDIT

With subref, you can do it in one liner like this :

byte = subsref(whos('x'),struct('type','.','subs','bytes'));
like image 63
Vuwox Avatar answered Apr 26 '23 09:04

Vuwox