www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@coninputfactor/subsasgn.m
function cif = subsasgn(cif, S, B) %SUBSASGN Subscripted assignment for constraint factor objects % % CIF = SUBSASGN(CIF, S, B) % % CIF(I) = CIFb % CIF(I) = [] (term deletion) % % CIF.Name = {'Name1', ..., 'NameN'} % CIF.Symbol = {'Symbol1', ..., 'SymbolN'} % CIF.Unit = {'Unit1', ..., 'UnitN'} % CIF.Min = [mn1, ..., mnN] % CIF.Max = [mx1, ..., mxN] % CIF.Range = [mn1, ..., mnN; mx1, ..., mxN] % % CIF(I).Name = cell-string % CIF.Name(I) = cell-string % CIF.Name{I} = char % % See also CONBASE, CONINPUTFACTOR, CONINPUTFACTOR/SUBSREF. % Copyright 2004-2011 The MathWorks, Inc. if length( S ) == 1, switch S.type, case '()', % CIF(I) = CIFb if numel( S(1).subs ) ~= 1, error(message('mbc:coninputfactor:InvalidPropertyValue')); elseif isempty( B ), % CIF(I) = []; i = S.subs{1}; cif.Name(i) = []; cif.Symbol(i) = []; cif.Unit(i) = []; cif.Min(i) = []; cif.Max(i) = []; if isempty( cif.Name ), cif = []; end elseif isa( B, 'coninputfactor' ), i = S.subs{1}; if numel( i ) ~= length( B ) && length( B ) ~= 1, error(message('mbc:coninputfactor:InvalidPropertyValue1')); end cif.Name(i) = B.Name; cif.Symbol(i) = B.Symbol; cif.Unit(i) = B.Unit; cif.Min(i) = B.Min; cif.Max(i) = B.Max; % Make sure any columns are now rows. cif = p_EnsureRows( cif ); else error(message('mbc:coninputfactor:InvalidPropertyValue2')); end case '.', % CIF.Name = {'Name1', ..., 'NameN'} fn = lower( S.subs ); fn(1) = upper( fn(1) ); switch fn, case {'Name', 'Symbol', 'Unit'}, if ischar( B ) && size( cif, 2 ) == 1, cif.(fn) = {B}; elseif iscellstr( B ) && numel( B ) == length( cif ), cif.(fn) = B; else error(message('mbc:coninputfactor:InvalidPropertyValue3', fn)); end case {'Min', 'Max'}, if isnumeric( B ) && ( numel( B ) == length( cif ) || numel( B ) == 1 ), cif.(fn) = B; else error(message('mbc:coninputfactor:InvalidPropertyValue4', fn)); end case 'Range', if isnumeric( B ) && size( B, 2 ) == length( cif ), cif.Min = B(1,:); cif.Max = B(2,:); else error(message('mbc:coninputfactor:InvalidPropertyValue5')); end otherwise error(message('mbc:coninputfactor:InvalidPropertyName')); end % Make sure any columns are now rows. cif = p_EnsureRows( cif ); case '{}', error(message('mbc:coninputfactor:InvalidArguments18')); otherwise error(message('mbc:coninputfactor:InvalidArguments19')); end elseif length( S ) == 2, % CIF(I).Name = cell-string % CIF.Name(I) = cell-string % CIF.Name{I} = char tmp = subsref( cif, S(1) ); tmp = subsasgn( tmp, S(2), B ); cif = subsasgn( cif, S(1), tmp ); else error(message('mbc:coninputfactor:InvalidArguments20')); end %------------------------------------------------------------------------------| % EOF %------------------------------------------------------------------------------|