MATLAB: How to get Dependent Property depending on properties of objects of different class

classdependent propertyoop

See the code below:
Ex_ObjA.m–>
classdef Ex_ObjA
properties
a
end
methods
function Obj=Ex_ObjA(t)
Obj.a = t;
end
end
end
Ex_ObjBC.m–>
classdef Ex_ObjBC
properties
b
end
properties (Dependent = true, SetAccess = public)
c
end
methods
function Obj=Ex_ObjBC(t)
Obj.b = t;
end
function c=get.c(Obj,s1) % error: Get methods must have exactly one input
c = Obj.b + s1.a;
end
end
end
I tried to do following:
s1 = Ex_ObjA(2);
s2 = Ex_ObjBC(3);
s2.c
Not successful, because "Get methods must have exactly one input". So I can pass the s1.a to Ex_ObjBC to get s1.c?
Much appreciation!!!

Best Answer

There's no apparent reason why c should be a property, Dependent or otherwise. You could just write the class this way,
classdef Ex_ObjBC
properties
b
end
methods
function Obj=Ex_ObjBC(t)
Obj.b = t;
end
function out=c(Obj,s1)
out = Obj.b + s1.a;
end
end
end