clear; % instantiate an object of type BasicClass (see BasicClass.m) obj = BasicClass; assert(isempty(obj.Value)); obj.Value = 3; obj.Value = [3 4.5]; % methods can be called in two ways roundOff(obj); % or dot notation obj.roundOff(); % use the constructor v = BasicClass(42); assert(v.Value == 42); % all properties can be enumerated assert(isequal(properties(v), {'Value'}')); % and all methods assert(isequal(methods(v), {'BasicClass', 'multiplyBy', 'plus', 'roundOff'}')); % object arrays are presto supported objs(1) = BasicClass(44); objs(2) = BasicClass(33); % [objs.Value] expands to [objs(1).Value ...] assert(isequal( [objs.Value], [44 33] )); % you can also do this with a cell array assert(isequal( {objs.Value}, {44, 33} )); % operator overloading v + v; % also works for object arrays [objs] + [objs];