1classdef struct_wrapper 2 properties 3 s; 4 end 5 methods 6 function o = struct_wrapper () 7 if (nargin == 0) 8 o.s = struct (); 9 else 10 error ('struct_wrapper:SyntaxError', ... 11 'struct_wrapper: Invalid syntax'); 12 end 13 end 14 function n = numel (o, varargin) 15 n = 1; 16 end 17 function varargout = subsref (o, p) 18 if (isequal (p(1).type, '{}')) 19 r = []; 20 for i = 1:numel (p(1).subs) 21 r = [r, getfield(o.s, p(1).subs{i})]; 22 end 23 varargout = {r}; 24 else 25 error ('struct_wrapper:SyntaxError', ... 26 'struct_wrapper: Invalid syntax'); 27 end 28 end 29 function o = subsasgn (o, p, varargin) 30 if (isequal (p(1).type, '{}')) 31 for i = 1:numel (p(1).subs) 32 o.s = setfield (o.s, p(1).subs{i}, varargin{1}(i)); 33 end 34 else 35 error ('struct_wrapper:SyntaxError', ... 36 'struct_wrapper: Invalid syntax'); 37 end 38 end 39 end 40end 41