Running the matlab class example

12 ビュー (過去 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 Center および File ExchangeWhos についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by