%% Align a Signal and a Periodic Repetition of It
% Align signal Y with respect to X, despite the fact that Y is a periodic repetition of X. Return the smallest possible delay.
% Create two signals, X and Y. Y consists of two copies of the nonzero portion of X separated by zeros. Align the two signals.

X = [0 1 2 3];
Y = [1 2 3 0 0 0 0 1 2 3 0 0];

[Xa,Ya,D] = alignsignals(X,Y)

% Copyright 2015 The MathWorks, Inc.