Class properties are being reinitialized each time I call a method
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Phased Array System Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!