识别信号之间的相移 [英] identifying phase shift between signals

查看:143
本文介绍了识别信号之间的相移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我产生了三个相同的波,每个波都有一个相移.例如:

t = 1:10800; % generate time vector
fs = 1; % sampling frequency (seconds)
A = 2; % amplitude
P = 1000; % period (seconds), the time it takes for the signal to repeat itself
f1 = 1/P; % number of cycles per second (i.e. how often the signal repeats itself every second).
y1 = A*sin(2*pi*f1*t); % signal 1
phi = 10; % phase shift
y2 = A*sin(2*pi*f1*t + phi); % signal 2
phi = 15; % phase shift
y3 = A*sin(2*pi*f1*t + phi); % signal 3

YY = [y1',y2',y3'];

plot(t,YY)

我现在想使用一种检测波之间相移的方法.这样做的目的是使我最终可以将该方法应用于实际数据,并确定信号之间的相移.

到目前为止,我一直在考虑计算每个波与第一个波之间的交叉谱(即没有相移):

for i = 1:3;
    [Pxy,Freq] = cpsd(YY(:,1),YY(:,i));
    coP = real(Pxy);
    quadP = imag(Pxy);
    phase(:,i) = atan2(coP,quadP);
end

但是我不确定这是否有意义.

还有其他人做过类似的事情吗?对于波2和3,所需的结果应分别在10和15处显示相移.

任何建议将不胜感激.

解决方案

有几种方法可以测量信号之间的相移.在您的回应,回应下方的评论以及其他答案之间,您已经获得了大多数选择.具体的技术选择通常基于以下问题:

  • 嘈杂或干净:信号中是否有噪声?
  • 多分量或单分量:录音中是否存在一种以上类型的信号(多个音调在不同方向上移动的多个音调)?或者,是否只有一个信号,例如您的正弦波示例?
  • 瞬时或平均:您是在整个记录中寻找平均相位滞后,还是在跟踪整个记录中的相位变化?

根据您对这些问题的回答,可以考虑以下技术:

  • Cross-Correlation :使用类似[c,lag]=xcorr(y1,y2);的命令来获取两个信号之间的互相关.这适用于原始的时域信号.您在c为最大值([maxC,I]=max(c);)的位置寻找索引,然后以样本lag = lag(I);为单位获取滞后值.这种方法为您提供了整个记录的平均相位滞后.它要求您对录音感兴趣的信号要强于录音中的任何其他信号……换句话说,它对噪声和其他干扰敏感.

  • 频率域:在这里,您可以将信号转换为频域(使用fftcpsd或其他方法).然后,您将找到与您关心的频率相对应的bin,并获得两个信号之间的角度.因此,例如,如果bin#18对应于信号的频率,则可以通过phase_rad = angle(fft_y1(18)/fft_y2(18));获得弧度的相位滞后.如果您的信号具有恒定的频率,则这是一种极好的方法,因为它自然会抑制所有噪声和其他频率的干扰.您可能在一个频率上确实有很强的干扰,但是仍然可以在另一个频率上干净地接收信号.对于在fft分析窗口期间更改频率的信号,此技术不是最佳方法.

  • 希尔伯特变换:通常被忽略的第三种技术是通过希尔伯特变换将y1_h = hilbert(y1);转换为时域信号为解析信号.一旦执行此操作,您的信号就是复数的向量.现在,在时域中持有简单正弦波的向量将是复数向量,其幅值是恒定的,并且其相位与原始正弦波同步变化.此技术使您可以获取两个信号之间的瞬时相位滞后...功能强大:phase_rad = angle(y1_h ./ y2_h);phase_rad = wrap(angle(y1_h) - angle(y2_h));.这种方法的主要限制是您的信号必须是单分量的,这意味着您感兴趣的信号必须支配您的录音.因此,您可能必须过滤掉可能存在的任何实质性干扰.

I have generated three identical waves with a phase shift in each. For example:

t = 1:10800; % generate time vector
fs = 1; % sampling frequency (seconds)
A = 2; % amplitude
P = 1000; % period (seconds), the time it takes for the signal to repeat itself
f1 = 1/P; % number of cycles per second (i.e. how often the signal repeats itself every second).
y1 = A*sin(2*pi*f1*t); % signal 1
phi = 10; % phase shift
y2 = A*sin(2*pi*f1*t + phi); % signal 2
phi = 15; % phase shift
y3 = A*sin(2*pi*f1*t + phi); % signal 3

YY = [y1',y2',y3'];

plot(t,YY)

I would now like to use a method for detecting this phase shift between the waves. The point of doing this is so that I can eventually apply the method to real data and identify phase shifts between signals.

So far I have been thinking of computing the cross spectra between each wave and the first wave (i.e. without the phase shift):

for i = 1:3;
    [Pxy,Freq] = cpsd(YY(:,1),YY(:,i));
    coP = real(Pxy);
    quadP = imag(Pxy);
    phase(:,i) = atan2(coP,quadP);
end

but I'm not sure if this makes any sense.

Has anyone else done something similar to this? The desired outcome should show a phase shift at 10 and 15 for waves 2 and 3 respectively.

Any advice would be appreciated.

解决方案

There are several ways that you can measure the phase shift between signals. Between your response, the comments below your response, and the other answers, you've gotten most of the options. The specific choice of technique is usually based on issues such as:

  • Noisy or Clean: Is there noise in your signal?
  • Multi-Component or Single-Component: Are there more than one type of signal within your recording (multiple tones at multiple frequencies moving in different directions)? Or, is there just a single signal, like in your sine-wave example?
  • Instantaneous or Averaged: Are you looking for the average phase lag across your entire recording, or are you looking to track how the phase changes throughout the recording?

Depending on your answer to these questions, you could consider the following techniques:

  • Cross-Correlation: Use the a command like [c,lag]=xcorr(y1,y2); to get the cross-correlation between the two signals. This works on the original time-domain signals. You look for the index where c is maximum ([maxC,I]=max(c);) and then you get your lag value in units of samples lag = lag(I);. This approach gives you the average phase lag for the entire recording. It requires that your signal of interest in the recording be stronger than anything else in your recording...in other words, it is sensitive to noise and other interference.

  • Frequency Domain: Here you convert your signals into the frequency domain (using fft or cpsd or whatever). Then, you'd find the bin that corresponds to the frequency that you care about and get the angle between the two signals. So, for example, if bin #18 corresponds to your signal's frequency, you'd get the phase lag in radians via phase_rad = angle(fft_y1(18)/fft_y2(18));. If your signals have a constant frequency, this is an excellent approach because it naturally rejects all noise and interference at other frequencies. You can have really strong interference at one frequency, but you can still cleanly get your signal at another frequency. This technique is not the best for signals that change frequency during the fft analysis window.

  • Hilbert Transform: A third technique, often overlooked, is to convert your time-domain signal into an analytic signal via the Hilbert transform: y1_h = hilbert(y1);. Once you do this, your signal is a vector of complex numbers. A vector holding a simple sine wave in the time domain will now be a vector of complex numbers whose magnitude is constant and whose phase is changing in sync with your original sine wave. This technique allows you to get the instantaneous phase lag between two signals...it's powerful: phase_rad = angle(y1_h ./ y2_h); or phase_rad = wrap(angle(y1_h) - angle(y2_h));. The major limitation to this approach is that your signal needs to be mono-component, meaning that your signal of interest must dominate your recording. Therefore, you may have to filter out any substantial interference that might exist.

这篇关于识别信号之间的相移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆