view general/arrutils/lags.m @ 42:ae596261e75f

Various fixes and development to audio handling
author samer
date Tue, 02 Dec 2014 14:51:13 +0000
parents e44f49929e56
children
line wrap: on
line source
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