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

    function S = expand(S,t)
%EXPAND Expand records into sweeps
%
%  S = EXPAND(S,t) turns each record into a sweep by replicating it N
%  times.  The number of times to replicate each record is specified by the
%  (1-by-NUMRECS) vector t.

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


s= size(S);
if s(1)~=s(3) || length(t)~=s(3)
    error(message('mbc:sweepset:InvalidArgument3'));
end

bd1= S.baddata;
d1= S.data;

d2= zeros(sum(t),s(2));
bd2= sparse(d2);

j=1;
for i = 1:length(t);
	d2(j:j+t(i)-1,:)= d1(i*ones(t(i),1),:);
	bd2(j:j+t(i)-1,:)= bd1(i*ones(t(i),1),:);
	j= j+t(i);
end
S.data= d2;
S.baddata= bd2;
S.xregdataset= xregdataset(testnum(S),type(S),t);