Is there a callback to check if any of the objects properties are changed using OOP in MATLAB 7.6 ( R2008a)?
1 view (last 30 days)
Show older comments
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?
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
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
0 Comments
More Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!