subsref.m

来自「HERE IS A GOOD PSO TOOL BOX」· M 代码 · 共 45 行

M
45
字号
function B = subsref(A,S)% GPCONSTRAINT/SUBSREF method%% one subscripting levelif length(S) == 1   switch S.type  case '.'    switch S.subs      case 'lhs'        B = A.lhs;      case 'rhs'        B = A.rhs;      case 'type'        B = A.type;      case 'gpvars'        B = A.gpvars;      otherwise        error('GP constraint indexing error');    end  case '()'    B = A(S.subs{:});  otherwise    error(['GP constraint indexing with ' S.type ' is not supported']) ;  end% two level subscriptingelseif length(S) == 2  if ( strcmp(S(1).type,'()') && strcmp(S(2).type,'.') )    switch S(2).subs      case 'lhs'        B = A(S(1).subs{:}).lhs;      case 'rhs'        B = A(S(1).subs{:}).rhs;      case 'type'        B = A(S(1).subs{:}).type;      case 'gpvars'        B = A(S(1).subs{:}).gpvars;      otherwise        error('GP constraint indexing error');    end  endelse  error('Such GP constraint indexing is not supported');end  

⌨️ 快捷键说明

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