Using builtin subsref make different results
1 view (last 30 days)
Show older comments
Hello, currently in my project I am overloading subsref function and I am little bit confused, because I overload some cases, for other I am still using builtin subsref function.
On example I have created 2 simple classes:
classdef example < handle
properties
cellArray
end
methods
function obj = example()
obj.cellArray{1} = 'first';
obj.cellArray{2} = 'second';
end
function varargout = subsref(obj, s)
[varargout{1}] = builtin('subsref', obj, s);
end
end
end
and second one:
classdef example2 < handle
properties
cellArray
end
methods
function obj = example2()
obj.cellArray{1} = 'first';
obj.cellArray{2} = 'second';
end
end
end
This classes seems similar, but in some cases the results is different, for example:
obj1 = example;
obj2 = example2;
Now, when I want display cellArray as:
>> obj1.cellArray{:}
ans =
first
>> obj2.cellArray{:}
ans =
first
ans =
second
>>
So as can be seen the output of the individual classes is different, and its making me mess in further code development, do you have any tips how to change class example to work exactly like example2 class?
Answers (0)
See Also
Categories
Find more on Construct and Work with Object Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!