www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@sweepset/issubset.m
function OK = issubset(D1, D2, KEEP_SWEEP_ORDER) %ISSUBSET True if a sweepset is a subset of a second sweepset. % % ISSUBSET( SS1, SS2 ) returns true is SS1 is a subset of SS2 % % Copyright 2000-2010 The MathWorks, Inc. and Ford Global Technologies, Inc. s1= size(D1); s2= size(D2); % Make sure that D1 has fewer sweeps than D2 and contains the same testnums sok = isa(D1, 'sweepset') && isa(D2, 'sweepset') && s1(3)<=s2(3) && all( ismember(testnum(D1),testnum(D2)) ); if ~sok OK = 0; return; end varInd = find(D2,get(D1,'Name')); VarReord = ~isequal(varInd, (1:length(varInd)).'); OK=0; if sok && ~isempty(varInd); SweepReord = false; if nargin < 3 || ~KEEP_SWEEP_ORDER T1= testnum(D1); T2= testnum(D2); % Duplicate testnums will throw this so return if duplicates found if length(unique(T2)) ~= length(T2) return end SInd= zeros(1,length(T1)); [tnumSort,tnumInd]= sort(T2); for i=1:length(T1) tmp= mbcbinsearch(tnumSort,T1(i)); SInd(i)= tnumInd(tmp); SweepReord = SweepReord || SInd(i)~=i; end else SInd = ':'; end if SweepReord || VarReord S = substruct('()' , {':',varInd,SInd} ); D2 = subsref(D2, S); end OK = isequal(tsizes(D2), tsizes(D1)) && isequaln(D2.data, D1.data); end