MATLAB: Problem with object oriented progamming – codepedent variables

"object" "oriented" "progamming" "codepedent" "matlab" "code"oop

Hello guys, I've got a problem with a class of the object that I want to create. I want it to work in that way: Once I change the parameter 'A', I want second parameter 'B' to change automatically, and once I change the second parameter 'B' I want the first parameter 'A' change adequatly:
classdef ModelBrick
properties
A=1
B=1
end
methods
function a= set.A(obj)
obj.A=a*obj.B;
end
function b= set.B(obj)
obj.B=obj.A/b;
end
end
end
Obviously it doesn't work. It enters into infinit loop. Do you have any idea how to deal with this problem? Thank you in advance.

Best Answer

Thanks a lot Matt for your time. I found the answer thank to you.
classdef ModelBrick
properties
B=1
C=20
end
properties(Dependent = true)
A=1
end % end of dependent properties
methods
function obj= set.A(obj,a)
obj.B=a/obj.C
end
function a= get.A(obj)
a=obj.B*obj.C;
end
end
end