I have created a custom class Foo and has overloaded the SIZE method for it:
classdef Foo properties data end methods function this = Foo(x) this.data = x; end function res = size(this) res = size(this.data); end endend
I then create an array of Foo objects and try to find its size
v=[Foo(2) Foo(1) Foo(3)];size(v)
The SIZE method does not work on this array, as expected and returns an error:
??? Error using ==> size Too many input arguments. Error in ==> Foo>Foo.size at 22 res = size(this.data);
However, the DISP method works on this array and shows that the size of the array is 1×3. I expected the DISP method to call the size method of the class and therefore error as before.
display(v) 1x3 Foo Properties: data Methods
Best Answer