www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/@mbcmodel/@data/RemoveVariable.m

    function D = RemoveVariable(D, index)
%REMOVEVARIABLE Remove a user-defined variable from a data set.
%
%   D = REMOVEVARIABLE(D, VARIABLE_INDEX);
%
%   See also mbcmodel.data.AddVariable, mbcmodel.data.ModifyVariable.

%   Copyright 2004-2007 The MathWorks, Inc.

error(mbcnargchk(2, 2, nargin, 'mbc:mbcmodel:data'));

% Make sure that the object is editable
D.pCheckIsBeingEdited;
try
    % Make sure the index is correct
    if index < 1 
        error(message('mbc:mbcmodel:data:InvalidIndex15'));
    end
    if index > numVariables(D.Object)
        error(message('mbc:mbcmodel:data:InvalidIndex16'));                
    end
    % Call the underlying method
    D.Object = removeVariable(D.Object, index);
catch E
    [mnemonic, component] = mbcGetLastError(E);
    switch [component ':' mnemonic]
        case 'data:InvalidIndex'
            error('mbc:mbcmodel:data:InvalidIndex17', E.message);                
        otherwise
            error(message('mbc:mbcmodel:data:UnknownError14'));    
    end
end