📄 subsref.m
字号:
function b = subsref(s,index)
% SUBSREF Define field name indexing for stock objects
fc = fieldcount(s.asset);
switch index.type
case '()'
if (index.subs{:} <= fc)
b = subsref(s.asset,index);
else
switch index.subs{:} - fc
case 1
b = s.numShares;
case 2
b = s.sharePrice;
otherwise
error(['Index must be in the range 1 to ', ...
num2str(fc + 2)])
end
end
case '.'
switch index.subs
case 'numShares'
b = s.numShares;
case 'sharePrice'
b = s.sharePrice;
otherwise
b = subsref(s.asset,index);
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -