www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@mdev_local/RestoreData.m

    function mdev = RestoreData(mdev, OutlierIndices)
%RESTOREDATA Restore data previously removed as outliers
%
%   RESTOREDATA( LOCALRESPONSE, OutlierIndices ) restores all removed data
%   specified in OutlierIndices
%   RESTOREDATA( LOCALRESPONSE ) restores all removed data
%   All response feature models are refitted.
%
%  See also MDEV_LOCAL/REMOVEOUTLIERSFORTEST, MODELDEV/REMOVEOUTLIERS.


%  Copyright 2006 The MathWorks, Inc. and Ford Global Technologies, Inc.



if nargin<2
    OutlierIndices = ':';
end

Yall = getdata(mdev);
Nrec= size(Yall,1);
NewOutliers = [];

if islogical(OutlierIndices)
    OutlierIndices= find(OutlierIndices);
end
  
if ~isempty(OutlierIndices)
    % outlier indices specified
    
    if min(OutlierIndices)<1 || max(OutlierIndices)>Nrec;
        error(message('mbc:modeldev:InvalidIndex'))
    end
    NewOutliers = OutlierIndices(:);   
elseif strcmp(OutlierIndices,':')
    % restore all outliers
    NewOutliers = outliers(mdev);
end

if ~isempty(NewOutliers)    
    % update outliers
    NewOutliers= setdiff(outliers(mdev) ,  NewOutliers);
    mdev= info( outliers(mdev,NewOutliers) );
    
    % fit local models
    [OK,mdev]= fitmodel(mdev);
    % refit response features
    mdev = UpdateLinks(mdev,2);
end