Running the matlab class example

조회 수: 16 (최근 30일)
Gopalakrishnan venkatesan
Gopalakrishnan venkatesan 2016년 8월 3일
편집: per isakson 2016년 8월 9일
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

채택된 답변

Adam
Adam 2016년 8월 3일
편집: Adam 2016년 8월 3일
t = Testpoint; % Create the object
t.expectedResult = 7; % Set the property
t.expectedResult % Get the property
for example.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by