www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@sweepsetfilter/private/ApplyObject.m

    function out = ApplyObject(obj, flagIn, ssIn)
%APPLYOBJECT  Apply the filters to the underlying object
%
%  SS = APPLYOBJECT(OBJ, FLAGS) where flags is a bitwise scalar which is
%  used to turn on and off certain operations see the private function
%  GETFLAGS for the flag values  
%
%  See also SWEEPSETFILTER/PRIVATE/GETFLAGS.

%  SS = APPLYOBJECT(OBJ, FLAGS, SSIN) is intended for private functions to
%  systematically build up a copy of the underlying sweepset efficiently.

%  Copyright 2000-2015 The MathWorks, Inc. and Ford Global Technologies, Inc.


% Shortcut using cached sweepset
if nargin == 1 && obj.allowsCacheing && isobject(obj.cachedSweepset)
    out = obj.cachedSweepset;
    return
end

flags = obj.allowsFlag;
if nargin > 1
	% Set all flags on
	flags = bitand(flags, xregbitset(flagIn));
end

% Get the flag definitions
f = getFlags;

% Make sure we initialise out correctly
if ~isvalid(obj.pSweepset)
    out = sweepset;
    return
end

% Make sure that we get the sweepset version of the output object, complete
% with record and variable indices

% nargin > 2 intended for private functions to systematically build up
% a copy of the underlying sweepset efficiently
if nargin > 2
    out = ssIn;
elseif isa(obj.pSweepset.info, 'sweepset')
    out = obj.pSweepset.info;
else
    out = sweepset(obj.pSweepset.info);
end


% First modify the data with the sparse modifyData information
% Temp copy of the modifyData field
if bitget(flags, f.APPLY_DATA) && any(obj.modifiedData.fullPosition(:))
    md = obj.modifiedData;
    % Now subsasgn into the sweepset
    out(md.fullPosition) = md.dataValues(md.dataPosition);
end


% Second append any user-defined variables
if bitget(flags, f.APPLY_VARS) && ~isempty(obj.variableSweepset)
	out = [out obj.variableSweepset];
end

% Third apply record filters
if bitget(flags, f.APPLY_FILT) && ~isempty(obj.recordsToRemove)
	out = filter(out, obj.recordsToRemove, [], []);
end

% Fourth change the test definitions
if  bitget(flags, f.APPLY_TEST) && ~isempty(obj.defineTests)
	args = struct2cell(obj.defineTests);
	out = DefineSweepSet(out, args{:});
end

% Fifth apply sweep variables
if bitget(flags, f.APPLY_SVAR) && ~isempty(obj.sweepVariableSweepset) 
	out = [out obj.sweepVariableSweepset];
end

% Sixth apply sweep filters and variable filters
if bitget(flags, f.APPLY_SFILT) ...
        && (~isempty(obj.sweepsToRemove) || ~isempty(obj.variablesToKeep))
    if iscell(obj.sweepsToRemove) && numel(obj.sweepsToRemove)==2
        % remove records or sweeps
        out = filter(out, obj.sweepsToRemove{1},  obj.variablesToKeep, obj.sweepsToRemove{2});
    else
        out = filter(out, [],  obj.variablesToKeep, obj.sweepsToRemove);
    end
end

% Seventh reorder the sweeps
if bitget(flags, f.APPLY_REOR) && ~isempty(obj.reorderSweeps)
	out = out(:,:,obj.reorderSweeps{1});
end

% Eighth perform any necessary resample
if bitget( flags, f.APPLY_RESAMP ) ...
        && obj.resampling.OK && ~isempty( obj.resampling.resampledSweepset )
    out = obj.resampling.resampledSweepset;
end

% Lastly call a derived class to apply whatever changes they have defined
if bitget(flags, f.APPLY_DERIVED)
    out = pAfterSweepsetfilterApplyObject(obj, out);
end