changeset 467:8d3c3da3a589 feature/sublassable_cellarray

Initial commit
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 01 Aug 2017 09:28:10 +0200
parents e1a59aafe99c
children 13362cf4dd89
files Cell.m
diffstat 1 files changed, 64 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Cell.m	Tue Aug 01 09:28:10 2017 +0200
@@ -0,0 +1,64 @@
+classdef Cell
+    properties
+        data
+    end
+    methods
+        function obj = Cell(data)
+            if ~iscell(data)
+                class(data)
+                error('Input argument to Cell must be a cell array')
+            end
+
+            obj.data = data;
+        end
+
+        % function display(A)
+        %     n = size(A.data);
+
+        %     sizeStr = join(cellfun(@num2str, num2cell(n), 'UniformOutput',false),'x');
+        %     header = [sizeStr, 'Cell']
+
+        %     disp()
+        %     disp(A.data)
+        %     % display(A.data)
+        % end
+
+        function disp(A)
+            disp(A.data)
+        end
+
+        function A = subsasgn(A, S, B)
+            disp(S);
+            a = subsasgn(A.data, S, B);
+            A = Cell(a);
+        end
+
+        function B = subsref(A, S)
+            disp(S);
+            B = subsref(A.data, S);
+            % Wrong if type is '()', '.'
+        end
+
+        function C = horzcat(varargin)
+            dataArray = cell(1, length(varargin));
+
+            for i = 1:length(varargin)
+                dataArray{i} = varargin{i}.data;
+            end
+
+            c = horzcat(dataArray{:});
+            C = Cell(c);
+        end
+
+        function vertcat(varargin)
+            dataArray = cell(1, length(varargin));
+
+            for i = 1:length(varargin)
+                dataArray{i} = varargin{i}.data;
+            end
+
+            c = vertcat(dataArray{:});
+            C = Cell(c);
+        end
+    end
+end
\ No newline at end of file