When you wanna instantiate an object. First you need creat a class or you already have a class. Then you use a class to instantiate an object.
Or you already object, then you copy a object .
But look this code. I make a breakingpoint in 15th line of ClassB 'switch src.Name',then excute:
>> obj_a=ClassA;
>> obj_b=ClassB(obj_a);
>> obj_a.x=3;
When the program runs to 15th line of ClassB.m . I found 'src' is a 'meta.property 'object! Why does the callback function create an 'meta.property 'object? How does the callback function create an 'meta.property 'object?
I check the addlistener ,this function allow to input 'meta.property 'object for 'PropertyName' ,but it dose not creat a 'meta.property 'object. Obviously 'x' as the input arguments of the addlistener function(7th line of ClassB.m) is the character, not the 'meta.property' object.
ClassA.m
properties (SetObservable)
ClassB.m
function obj = ClassB(event_obj)
addlistener(event_obj,'x','PreSet',@ClassB.eventsCBFunc);
addlistener(event_obj,'y','PostSet',@ClassB.eventsCBFunc);
function eventsCBFunc(src,evnt)
fprintf(['Current event:' evnt.EventName]);
fprintf(1,' \n x is %s\n',num2str(evnt.AffectedObject.x))
fprintf(['Current event:' evnt.EventName]);
fprintf(1,' \n y is %s\n',num2str(evnt.AffectedObject.y))