set.m

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

M
21
字号
function s = set(s,varargin)
% SET Set stock properties to the specified values
% and return the updated object
propertyArgIn = varargin;
while length(propertyArgIn) >= 2,
   prop = propertyArgIn{1};
   val = propertyArgIn{2};
   propertyArgIn = propertyArgIn(3:end);
   switch prop
   case 'NumberShares'
      s.numShares = val;
   case 'SharePrice'
      s.sharePrice = val;
   case 'Descriptor'
      s.asset = set(s.asset,'Descriptor',val);
   otherwise
      error('Invalid property')
   end
end
s.asset = set(s.asset,'CurrentValue',...
   s.numShares * s.sharePrice,'Date',date);

⌨️ 快捷键说明

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