The reason that the object is not displayed correctly in the Variable Editor when you overload the SIZE function, is that the Variable Editor calls SIZE with the following syntax:
[height, width] = size(var);
In this case, the overloaded SIZE method does not support this calling mechanism. This causes the call to SIZE to error, which causes the Variable Editor to call DISP instead and display the results.
To ensure that MATLAB functions that call SIZE internally behave correctly, your SIZE method should support all the syntaxes defined in the documentation for SIZE, that a caller of SIZE may reasonably expect to work, namely
d = size(X)
[m,n] = size(X)
m = size(X,dim)
[d1,d2,d3,...
The default SIZE and NUMEL functions should behave consistently with user-defined classes. However, if you change the way size behaves, ensure that the values returned make sense for the intended use of your class.
Best Answer