Mercurial > repos > public > sbplib
diff Cell.m @ 467:8d3c3da3a589 feature/sublassable_cellarray
Initial commit
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 01 Aug 2017 09:28:10 +0200 |
parents | |
children | 13362cf4dd89 |
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