MATLAB Object-Oriented Programming

(Joyce) #1

The property get methods applies a scale factor before returning its current value:


classdef Testpoint
properties
expectedResult = []
end
properties(Constant)
scalingFactor = 0.001
end
methods
function obj = set.expectedResult(obj,erIn)
if erIn >= 0 && erIn <= 100
erIn = erIn.*obj.scalingFactor;
obj.expectedResult = erIn;
else
obj.expectedResult = NaN;
end
end
function er = get.expectedResult(obj)
er = obj.expectedResult/obj.scalingFactor;
end
end
end


See Also


More About



  • “Properties Containing Objects” on page 8-66


See Also
Free download pdf