This function aligns the two input signals.
[Xa Ya] = ALIGNSIGNALS(X,Y) [Xa Ya] = ALIGNSIGNALS(X,Y,MAXLAG) [Xa Ya] = ALIGNSIGNALS(X,Y,MAXLAG,1) [Xa Ya D] = ALIGNSIGNALS(...)
[Xa Ya] = ALIGNSIGNALS(X,Y) aligns the two vectors X and Y by estimating the delay D between the two. If Y is delayed with respect to X, D is positive , and X is delayed by D samples. If Y is advanced with respect to X, D is negative, and Y is delayed by -D samples.
[Xa Ya] = ALIGNSIGNALS(X,Y,MAXLAG) considers MAXLAG be the maximum correlation window size which is used to calculate the estimated delay D between X and Y. MAXLAG is an integer-valued scalar. By default, MAXLAG is equal to MAX(LX,LY)-1. If MAXLAG is empty ([]),then default value is considered. If MAXLAG is negative, it is replaced by its absolute value.
[Xa Ya] = ALIGNSIGNALS(X,Y,MAXLAG,1) keeps the lengths of Xa and Ya the same as those of X and Y, respectively. Here, 1 implies truncation of the intermediate vectors. Input argument 4 is 0 implies truncation_off (no truncation). D is positive implies D zeros are pre-pended to X, and the last D samples of X are truncated. D is negative implies -D zeros are pre-pended to Y, and the last -D samples of Y are truncated. That means, when D>=Length(X), all samples of X are lost. Similarly, when -D>=Length(Y), all samples of Y are lost. Avoid assigning a specific value to MAXLAG when using the truncate=1 option, set MAXLAG to [].
[Xa Ya D] = ALIGNSIGNALS(...) returns the estimated delay D.