【问题标题】:How can I find phase angle for chosen frequency?如何找到所选频率的相位角?
【发布时间】:2016-02-18 13:34:01
【问题描述】:

我是 matlab 新手,所以我的问题可能很愚蠢。我有两个信号 rec(t) 和 sent(t) 我想通过从交叉频谱获得的相位与频率关系找到时间延迟。我通过rec(t)和sent(t)之间的互相关的FFT得到了交叉谱。这里是:

time=data(15:length(data),1);                                               %time of measurement - s
sent=data(15:length(data),2);                                               %sent signal - mV
rec=data(15:length(data),3);                                                %recorded signal - mV
samples=length(time);                                                       %number of samples
Fs=samples/max(time);                                                       %sampling frequency - Hz
dt=max(time)/samples;                                                       %time interval - s
freq=(0:samples/2)/samples/dt;                                              %frequency scale for FFT
FFTrec=fft(rec);                                                            %FFT of recorded signal
FFTsent=fft(sent);                                                          %FFT of sent signal
CorrRecSent=(ifft(FFTrec.*conj(FFTsent)));                                  %cross correlation definition
CS=fft(CorrRecSent);                                                        %cross spectrum (CS)
amp=abs(CS);                                                                %amplitude of CS
amp1=amp(1:samples/2+1);                                                    %amplitude of CS for half of the frequency spectrum
A2=angle(CS);
A1=A2(1:samples/2+1);                                                       %phase angle of (CS)
A=unwrap(A1);                                                               %unwrapped phase
plot(freq,(A));
xlabel('frequency (Hz)')
ylabel('phase (rad)')

这是情节。是否有任何命令或程序如何获得给定频率的精确相位角(用黑线标记)?或者我怎样才能找到绘制的橙色线的斜率?我选择了这个频率范围,因为我发送的信号是 5 kHz,所以选择了周围的东西。

感谢您的帮助。

【问题讨论】:

    标签: matlab frequency phase


    【解决方案1】:

    在图中,您将 freq 设置为 x 轴向量,将 A 设置为 y 轴向量。

    如果要知道橙色线的斜率,首先需要知道4000Hz和8000Hz所在的索引:

    f1 = find(freq==4000);
    f2 = find(freq==8000);
    

    那么你可以在这两点中检查哪个是相位:

    p1 = A(f1);
    p2 = A(f2);
    

    最后斜率将是 deltaX / deltaY:

    slope = (f2-f1)/(p2-p1);
    

    【讨论】:

    • 嗨 BlackAdder :) 感谢您的回复...它给了我这个结果 'p1 = Empty matrix: 0-by-1 p2 = Empty matrix: 0-by-1' 但我得到了很好的代码这里mathworks.com/matlabcentral/answers/…
    • 如果它给出空矩阵可能是因为你没有确切的 4000 和 8000Hz 的频率,所以 find 函数什么也不返回。然后你应该选择最近的。
    猜你喜欢
    • 1970-01-01
    • 2015-08-13
    • 2011-08-17
    • 1970-01-01
    • 2020-04-20
    • 1970-01-01
    • 1970-01-01
    • 2016-03-03
    • 1970-01-01
    相关资源
    最近更新 更多