function Y=lags(X,tau)
% lags - returns lagged versions of sequence in X
%
% lags :: [[N,T]], [[K]->integer]~'K lags' -> [[N,T2,K]].
% 
% T2 is the maxmimum length such that all lagged sequences contain valid data.

% doesn't work for data sequences yet
if isdata(X), X=head(X); end

tau=tau-min(tau); % zero base lags
[N T0]=size(X);
M=length(tau);
T=T0-max(tau);
Y=zeros(N,T,M);

tt=1:T; 
for i=1:length(tau)
	Y(:,:,i)=X(:,tau(i)+tt);
end
