MATLAB: Does the WHOS -FILE command output an empty matrix as the size of objects with an overloaded SIZE Method in MATLAB 7.7 (R2008b)

filematMATLABoverloadsize;whos

I have a MAT file that contains a user-defined MATLAB object. When I execute the following command
info = whos('-file','myObject.mat')
I get the following output
info =
name: 'm'
size: []
bytes: 56
class: 'mcosClass'
global: 0
sparse: 0
complex: 0
nesting: [1x1 struct]
persistent: 0
The size property is empty.

Best Answer

This is expected behavior.
MATLAB is unable to determine the true size of an object stored in a MAT-file if the class of this object overloads the MATLAB size function. For this reason, in previous versions of MATLAB, the command "whos -file" does not return or display object size accurately if the class of that object overloads these methods, but instead always returns 1x1 for the size.
In MATLAB 7.7 (R2008b), "whos -file" returns an empty matrix ([]) or displays a hyphen (-) for objects that overload size.
The above information can be found in the release notes at the following location
web([docroot '/techdoc/rn/bq08o1n-1.html#bq24lo5-1'])
To get the size of the object in this case you can either
1. Not overload the SIZE method, in which case
whos -file
will output the right size of the object.
2. Load the object into the workspace and then execute
size(object)
Related Question