Class properties are being reinitialized each time I call a method
Show older comments
Hi, class properties are being reinitialized each time I call a method. the result of the multiplication is always 15. Could you please tell me where is the error? I don't want to use any argument in the constructor method.
classdef Multi
properties
x = 0;
y = 0;
end
methods
function obj = Multi()
obj.x = 5;
obj.y = 3;
end
function obj = X (obj, x)
obj.x = x;
end
function obj = Y (obj, y)
obj.y = y;
end
function obj = Mul (obj)
disp (obj.x * obj.y);
end
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Phased Array System Toolbox 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!