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

    function P = RemoveData(P, D)
%REMOVEDATA Delete data from the project 
% 
%   REMOVEDATA(PROJECT, DATA) removes the data contained in the data object
%   DATA from the project. 
% 
%   REMOVEDATA(PROJECT, INDEX) removes the data at index INDEX from the
%   project.
%
%   REMOVADATA can error if the data that you request to remove is being
%   used by a testplan. To remove that data the associated testplan must
%   also be removed.
%
%   See also mbcmodel.project.CreateData, mbcmodel.project.CopyData.

%   Copyright 2004-2007 The MathWorks, Inc.

% Get the project
MP = P.Object;
% Get the list of data from the project
pAllData = dataptrs(MP);
% Is D an mbcmodel.data object or and integer
if isnumeric(D)
    try
        pData = pAllData(D);
    catch
        error('mbc:mbcmodel:project:InvalidArgument', ...
            'An integer index into the data array must be supplied');
    end
elseif isa(D, 'mbcmodel.data')
    index = findptrs(D.pGetPointerInstance, pAllData);
    % Did we find it?
    if index < 0
        error(message('mbc:mbcmodel:project:InvalidArgument6'));
    end
    pData = pAllData(index);
else
    error(message('mbc:mbcmodel:project:InvalidArgument7'));
end
% Is it testplan linked data
if isTestplanData(MP, pData)
    error(message('mbc:mbcmodel:project:InvalidState'));
end
% Remove the data
MP = removeData(MP, pData);