Set the private property of a class without using a constructor
이전 댓글 표시
I have a class and i just need to set the private property of the class without using constructor. Is this possible? So basically its this.
Classdef NumberClass
properties (Access = private)
Number;
end
methods
function obj = set.Number(obj,value)
obj.Number = value;
end
end
end
And then I tried to do this.
num = NumberClass;
num.Number = 50;
This doesnt work. I have also tried
function obj = Set(obj,value)
obj.Number = value;
end
num.Set(50);
Here there is no error but nothing happens.
So how can I set a private property in MATLAB without using constructor. Thank you.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Class Introspection and Metadata에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!