Main Content

alignsignals

通过延迟最早的信号来对齐两个信号

description

例子

[[xa,,,,ya] =对齐信号(X,,,,yestimates the delay,d,在两个输入信号之间,Xandy,,,,and returns the aligned signals,xaandya

  • 如果y延迟X, 然后d是积极的Xis delayed byd样品。

  • 如果y关于X, 然后dis negative andy被拖延了 -d样品。

延迟Xorycan be introduced by prepending zeros.

例子

[[xa,,,,ya] =对齐信号(X,,,,y,,,,maxlagusesmaxlagas the maximum window size to find the estimated delay,d,在两个输入信号之间,Xandy。它返回对齐信号,xaandya

例子

[[xa,,,,ya] =对齐信号(X,,,,y,,,,maxlag,'截短')保持对齐信号的长度,xaandya,,,,the same as those of the input signals,Xandy, 分别。

  • 如果估计延迟,d,是积极的,那么dzeros are prepended toX最后dsamples ofXare truncated.

  • 如果估计延迟,d,那是负面的 -dzeros are prepended toy最后-dsamples ofyare truncated.

笔记

Xandy是长的行还是列的长度向量lXandly, 分别。

  • 如果dlX, 然后xa由组成lXzeros. All samples ofXare lost.

  • 如果-dly, 然后ya由组成lyzeros. All samples ofyare lost.

To avoid assigning a specific value tomaxlag使用时'截短'选项,设置maxlag[[]

例子

[[xa,,,,ya,,,,d] =对齐信号(___returns the estimated delay,d。该语法可以包括上一句语法中使用的任何输入参数。

Examples

collapse all

Align signaly关于Xby delaying it three samples.

Create two signals,XandyXis exactly the same asy, 除了Xhas three leading zeros and one additional following zero. Align the two signals.

X= [0 0 0 1 2 3 0 0]; Y = [1 2 3 0]; [Xa,Ya] = alignsignals(X,Y)
xa =1×80 0 01 2 3 0 0
ya =1×70 0 01 2 3 0

Align signalX什么时候y延迟X由两个样品。

Create two signals,Xandyyis exactly the same asX, 除了y有两个领先的零。对齐两个信号。

X= [1 2 3]; Y = [0 0 1 2 3]; maxlag = 2; [Xa,Ya,D] = alignsignals(X,Y,maxlag)
xa =1×50 0 1 2 3
ya =1×50 0 1 2 3
d = 2

Align signaly关于X,尽管事实是yis a noisy signal.

Create two signals,Xandyyis exactly the same asX添加了一些噪音。对齐两个信号。

x = [0 0 1 2 3 0];y = [0.02 0.12 1.08 2.21 2.95 -0.09];[xa,ya,d] =对齐信号(x,y)
xa =1×60 0 1 2 3 0
ya =1×60.0200 0.1200 1.0800 2.2100 2.9500 -0.0900
d = 0

您无需更改输入信号即可产生输出信号。延误d为零。

调用'截短'调用alignsignals功能。

Create two signals,Xandyyis exactly the same asX, 除了y有两个领先的零。Align the two signals, applying the'截短'指示。

X= [1 2 3]; Y = [0 0 1 2 3]; [Xa,Ya,D] = alignsignals(X,Y,[],'截短'
xa =1×30 0 1
ya =1×50 0 1 2 3
d = 2

观察输出信号xa长度为3,长度与输入信号相同X

在使用'截短'选项最终截断了所有原始数据X,发出警告。制作alignsignals发出这样的警告,运行以下示例。

y= [0 0 0 0 1 2 3]; [Xa,Ya,D] = alignsignals(X,Y,[],'截短'
Warning: All original data in the first input X has been truncated because the length of X is smaller than the estimated delay D: to avoid truncating this data do not use the 'truncate' option.
xa =1×30 0 0
ya =1×70 0 00 1 2 3
d = 4

Align signaly关于X,尽管事实是yis a periodic repetition ofX。Return the smallest possible delay.

Create two signals,Xandyy由两个非零部分的副本组成Xseparated by zeros. Align the two signals.

x = [0 1 2 3];y = [1 2 3 0 0 0 0 0 1 2 3 0 0];[xa,ya,d] =对齐信号(x,y)
xa =1×40 1 2 3
ya =1×130 1 2 3 0 0 0 0 1 2 3 0 0
d= -1

输入参数

collapse all

第一个输入信号,指定为长度的数字向量lX

Example:[1 2 3]

数据类型:单身的|double|int8|int16|int32|int64|UINT8|uint16|UINT32|Uint64
复杂的数字支持:金宝app是的

第二个输入信号,指定为长度的数字向量ly

Example:[0 0 1 2 3]

数据类型:单身的|double|int8|int16|int32|int64|UINT8|uint16|UINT32|Uint64
复杂的数字支持:金宝app是的

最大窗口大小或滞后,指定为整数值标量。默认,maxlag等于max(length(X),length(Y))-1。如果maxlag是输入[[],由默认值替换。如果maxlag为负,它被其绝对价值所取代。如果maxlagis not integer-valued, or is complex,Inf, 或者, 然后alignsignals返回错误。

Example:2

数据类型:单身的|double|int8|int16|int32|int64|UINT8|uint16|UINT32|Uint64

输出参数

collapse all

Aligned first signal, returned as a numeric vector that is aligned with the second output argument,ya。如果输入参数X是行矢量,然后xais also a row vector. If input argumentXis a column vector, thenxais also a column vector. If you specify the'截短'选项和估计延迟dis positive, thenxais equivalent to the input signalXd零及其最后一次d样品被截断。

Aligned second signal, returned as a numeric vector that is aligned with the first output argument,xa。如果输入参数y是行矢量,然后yais also a row vector. If input argumentyis a column vector, thenyais also a column vector. If you specify the'截短'选项和估计延迟dis negative, thenyais equivalent to the input signaly和 -d零及其最后一个 -d样品被截断。

输入信号之间的估计延迟,作为标量整数返回。该整数表示两个输入信号的样本数量,Xandy是偏移。

  • 如果y延迟X, 然后d是积极的Xis delayed byd样品。

  • 如果y关于X, 然后dis negative andy被拖延了 -d样品。

  • 如果Xandy已经对齐了d为零,都不X也不y被延迟。

如果you specify a value for the input argumentmaxlag, 然后d必须小于或等于maxlag

Algorithms

  • 您可以在规范中找到有关延迟估计的理论Finddelay函数(请参阅Algorithms)。

  • alignsignalsfunction uses the estimated delayd至delay the earliest signal such that the two signals have the same starting point.

  • 指定Finddelay功能,这对信号不必彼此延迟延迟。但是,只有当它们之间存在足够的相关性时,才能成功对齐信号。有关估计协方差和相关功能的更多信息,请参见[[1]

  • 如果your signals have features such as pulses or transitions, you can align them more effectively using measurement functions instead of correlation. For an example, see对齐两个二聚体波形

References

[[1] Orfanidis, Sophocles J.Optimum Signal Processing. An Introduction。第二版。新泽西州Englewood Cliffs:Prentice-Hall,1996年。

扩展功能

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

也可以看看

||||