how to call a get.properties method in a script
이전 댓글 표시
Hi, I'm trying to use the get.propertie function on a private propertie.
classdef t_point2D
properties (Access = private)
X;
Y;
end
methods
%Defenir le constructeur
function point2D = t_point2D(X,Y)
if nargin == 0
point2D.X =0;
point2D.Y=0;
elseif nargin == 1 || nargin >2
fprintf('Error');
else
point2D.X = X;
point2D.Y = Y;
end
end
%accesseurs
function X = get.X(point2D)
X = point2D.X;
end
Then, I try to call it in a script :
point1 =t_point2D(2,8);
XX = get.X(point1);
I get the following error message : Undefined variable "get" or class "get.X".
Error in test (line 4) XX = get.X(point1);
I supposed I'm not calling the method the right way? I can't find the doc on how to call a get.prop function.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Argument Definitions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!