467
|
1 classdef Cell
|
|
2 properties
|
|
3 data
|
|
4 end
|
|
5 methods
|
|
6 function obj = Cell(data)
|
|
7 if ~iscell(data)
|
|
8 class(data)
|
|
9 error('Input argument to Cell must be a cell array')
|
|
10 end
|
|
11
|
|
12 obj.data = data;
|
|
13 end
|
|
14
|
|
15 % function display(A)
|
|
16 % n = size(A.data);
|
|
17
|
|
18 % sizeStr = join(cellfun(@num2str, num2cell(n), 'UniformOutput',false),'x');
|
|
19 % header = [sizeStr, 'Cell']
|
|
20
|
|
21 % disp()
|
|
22 % disp(A.data)
|
|
23 % % display(A.data)
|
|
24 % end
|
|
25
|
|
26 function disp(A)
|
|
27 disp(A.data)
|
|
28 end
|
|
29
|
|
30 function A = subsasgn(A, S, B)
|
|
31 disp(S);
|
|
32 a = subsasgn(A.data, S, B);
|
|
33 A = Cell(a);
|
|
34 end
|
|
35
|
|
36 function B = subsref(A, S)
|
|
37 disp(S);
|
|
38 B = subsref(A.data, S);
|
|
39 % Wrong if type is '()', '.'
|
|
40 end
|
|
41
|
|
42 function C = horzcat(varargin)
|
|
43 dataArray = cell(1, length(varargin));
|
|
44
|
|
45 for i = 1:length(varargin)
|
|
46 dataArray{i} = varargin{i}.data;
|
|
47 end
|
|
48
|
|
49 c = horzcat(dataArray{:});
|
|
50 C = Cell(c);
|
|
51 end
|
|
52
|
|
53 function vertcat(varargin)
|
|
54 dataArray = cell(1, length(varargin));
|
|
55
|
|
56 for i = 1:length(varargin)
|
|
57 dataArray{i} = varargin{i}.data;
|
|
58 end
|
|
59
|
|
60 c = vertcat(dataArray{:});
|
|
61 C = Cell(c);
|
|
62 end
|
|
63 end
|
|
64 end |