%% X and Y Are Vectors, and maxlag Is Not Specified
% The following shows Y being delayed with respect to X by two samples.

X = [1 2 3];
Y = [0 0 1 2 3];
D = finddelay(X,Y)

%
% Here is a case of Y advanced with respect to X by three samples.

X = [0 0 0 1 2 3 0 0]';
Y = [1 2 3 0]';
D = finddelay(X,Y)

%
% The following illustrates a case where Y is aligned with X but is noisy.

X = [0 0 1 2 3 0];
Y = [0.02 0.12 1.08 2.21 2.95 -0.09];
D = finddelay(X,Y)

%
% If Y is a periodic version of X, the smallest possible delay is returned.

X = [0 1 2 3];
Y = [1 2 3 0 0 0 0 1 2 3 0 0];
D = finddelay(X,Y)

% Copyright 2015 The MathWorks, Inc.