%% Object Demostration script
% Simple script to run through some properties of MATLAB objects that we
% use in the Index tracker demostration.
clear classes; clc
%% Pass by reference
% DemoObject inherits from the handle class, so we can now do pass by
obj = DemoObject
obj.Value = 2
% Add a listener to the object and then send the event
L = addlistener(obj,'Catastrophe',@(src,evt) disp('Disaster Detected'));
% Objects can listen to events in other objects. Also events can carry data
% with them.
obj2 = DemoObject2;