Using builtin subsref make different results
1 次查看(过去 30 天)
显示 更早的评论
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?
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Construct and Work with Object Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!