-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuiltinHandleClass.m
57 lines (47 loc) · 1.27 KB
/
builtinHandleClass.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
classdef builtinHandleClass < handle
%arrayh - numeric array passed by reference
properties
data
end
methods
function obj = builtinHandleClass(data)
obj.data = data;
end
%% Overload builtin functions
function varargout = subsref(varargin)
obj = varargin{1};
S = varargin{2};
if length(S) == 1
switch S.type
case '.'
if nargout
[varargout{1:nargout}] = builtin('subsref',varargin{:});
else
builtin('subsref',varargin{:});
end
otherwise
if nargout
[varargout{1:nargout}] = builtin('subsref',obj.data,varargin{2:end});
else
builtin('subsref',obj.data,varargin{2:end});
end
end
end
end
function disp(obj, varargin)
disp(obj.data, varargin{:});
end
function out = length(obj, varargin)
out = length(obj.data, varargin{:});
end
function out = numel(obj, varargin)
out = numel(obj.data, varargin{:});
end
function out = num2str(obj, varargin)
out = num2str(obj.data, varargin{:});
end
function out = size(obj, varargin)
out = size(obj.data, varargin{:});
end
end
end