get.m

来自「matlab实用教程」· M 代码 · 共 18 行

M
18
字号
function val = get(s,propName)
% GET Get stock property from the specified object
% and return the value. Property names are: NumberShares
% SharePrice, Descriptor, Date, CurrentValue
switch propName
case 'NumberShares'
   val = s.numShares;
case 'SharePrice'
   val = s.sharePrice;
case 'Descriptor'
   val = get(s.asset,'Descriptor'); % call asset get method
case 'Date'
   val = get(s.asset,'Date');
case 'CurrentValue'
   val = get(s.asset,'CurrentValue');
otherwise
   error([propName ,'Is not a valid stock property'])
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?