subsref.m
来自「有关matlab的电子书籍有一定的帮助希望有用」· M 代码 · 共 45 行
M
45 行
function ans = subsref(obj,s)
%SUBSREF Method for fdax object
% Author: T. Krauss
% Copyright (c) 1988-98 by The MathWorks, Inc.
% $Revision: 1.3 $
if strcmp(s(1).type,'()')
obj = struct(obj);
obj = obj(s(1).subs{:});
obj = fdax(obj);
s(1) = [];
end
if isempty(s)
ans = obj;
return
end
switch s(1).type
case {'()','{}'}
error('Sorry, I don''t understand this construct.')
case '.'
ans = get(obj,s(1).subs);
end
if length(s)>1
% subsref into ans
ans = mysubsref(ans,s(2:end));
end
function ans = mysubsref(ans,s)
for i=1:length(s)
switch s(i).type
case '()'
ans = ans(s(i).subs{:});
case '{}'
ans = ans{s(i).subs{:}};
case '.'
ans = getfield(ans,s(i).subs);
end
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?