⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subsref.m

📁 利用电磁场的源激发方法来计算光子晶体波导例如光子晶体光纤
💻 M
字号:
function sub_obj = subsref(obj, s)

% SUBSREF	subsref function for pointers.

%   Copyright 2004, 2005 Nikolai Yu. Zolotykh
%   Thanks to Christoph Henninger for pointing out some bugs
%   and to Gang Liang for a lot of suggestions.

% In the implementation of this function we can not simply call it recursively
% because some subfields of subfields ... of subfields can be pointers too.
% If we call subsref recursively MATLAB try execute builtin('subsref')
% for this "sub-sub-...-sub-pointer" and fails with an error message.
%
% For example, if
%   a = pointer;
%   a.subfield1.subfield2 = pointer;
%   a.subfield1.subfield2.subfield3 = 'Hi';
% then
%   a, a.subfield1.subfield2 are pointers
%   a.subfield1 is a structure

n = length(s);
sub_obj = obj;

for j = 1:n
    if isa(sub_obj, 'pointer')
        switch s(j).type
            case {'()', '{}'}
                sub_obj = obj(s(j).subs{:});
            case '.'
                field = s(j).subs;
                [sub_obj, exst] = ref(sub_obj, field);
                if exst == 0
                    error(['Attemt to specify field ''' field ''' for NULL pointer']);
                end
                if exst == -1
                    error(['Specified field ''' field ''' does not exist']);
                end
        end
    else
        sub_obj = subsref(sub_obj, s(j));
    end;
end;

⌨️ 快捷键说明

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