MATLAB: Is there a callback to check if any of the objects properties are changed using OOP in MATLAB 7.6 ( R2008a)

callbackchangechangescheckdetectMATLABoop

I am working with object oriented programming (OOP) in MATLAB 7.6 (R2008a).
I am looking for a function which is called a if any of the objects properties are changed using the dot operator. How can this be done in MATLAB?

Best Answer

There is no easy way to do this. However you can use the SUBSASGN function which is used for subscripted assignment for objects. An example is given below:
classdef foo < handle
properties(SetObservable = true)
val = 1;
end
methods
function obj = subsasgn(obj, s, val)
disp('hello');
val = builtin('subsasgn', obj, s, val);
end
end
end
Now, at the MATLAB Command prompt, if you type:
f = foo;
f(1)
would give you the output:
ans =
foo handle
properties:
val: 1
lists of methods, events, superclasses
or typing
f.val
would give you the following output:
ans =
1