if true % code
endI am trying to use classes in MATLAB and I’m tripping over a property assignment in a class. I am trying to assign a value to a property in one function and read this property back in another function.
When I go to read the value back the value I assigned it no longer is applied to the property. I am not sure what I am doing wrong? Test class
classdef Class_Test %-------------------------------
% Properties
%------------------------------- properties (Access = private) X end %------------------------------- % Methods
%------------------------------- methods function set_X(this) this.X = 1; this.X end function read_X(this) this.X end endend
Output of Object:
>> TC = Class_Test;>> TC.set_Xans = 1>> TC.read_Xans = []
What I expected was:
>> TC.read_Xans =1
Best Answer