I have variables in MATLAB, I've checked their class using class()
but I also want to know the size that they take in the memory. More accurately, I know that they are of double type, and I want to make sure that they are 32-bit double and not 64-bit.
The version of the MATLAB I'm using is R2009b.
You can use whos to obtain an array of structures that describe, amongst other things, the size in bytes of each variable.
Note that a double is, by definition, 64-bit!
I wrote a simple convenience function to handle just this problem. Usage is:
I run R2007a, so the problem of Java objects not returning sizes may have been fixed in subsequent releases. Here's the code:
This will give you the size in megabytes, for example MB=123.78
I tried to enhance ' MatlabSorter's ' simple function to handle this problem. Usage is still the same:
additions :
1.you can state which type of return you seek for - b, kb, mb, tb or pb
2.you can get the result as a variable without printing it on the screen
Here's the code: