function y=delsig2(x,D)
%DELSIG2 Create delayed signal matrix from signal matrix and delay vector.
%
% DELSIG2(X,D)
% X - SxT matrix with S-element column vectors for T timesteps.
% D = [d1 d2 ... dn] - vector of delays.
% Returns signal X delayed by d1, ..., and dn timesteps
% and shorter than X by max(D).
% By Valery Petrov, CNLD 9-11-96
%
% Copyright (c) 1996-1998 The University of Texas at Austin
[xr,xc] = size(x);
d2=length(D);
if(xc<(max(D)-min(D)+1))
error('Not enough rows in x, for selected delay matrix !')
end
y = zeros(xr*(d2),xc-max(D));
for i=1:d2
y((1:xr)+xr*(i-1),:) = x(:,(max(D)-D(i)+1):(xc-D(i)));
end