MATLAB Answers

0

Running the matlab class example

Latest activity Edited by per isakson
on 9 Aug 2016
This is an example provided by MATLAB for ''Modify Property Values with Access Methods''. How to run this?
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

  0 Comments

Sign in to comment.

1 Answer

Answer by Adam
on 3 Aug 2016
Edited by Adam
on 3 Aug 2016
 Accepted Answer

t = Testpoint; % Create the object
t.expectedResult = 7; % Set the property
t.expectedResult % Get the property
for example.

  0 Comments

Sign in to comment.