필터 지우기
필터 지우기

Using builtin subsref make different results

조회 수: 1 (최근 30일)
Martin
Martin 2016년 9월 7일
댓글: per isakson 2016년 9월 14일
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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by