如何从信号中提取频率 [英] How to extract a frequency from a signal

查看:188
本文介绍了如何从信号中提取频率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种简单的方法来从信号中提取主频率/周期(不借助FFT)?

对于我的要求,这可能导致主频率(例如3Hz)的值或表示目标频率的强度的值。例如,在下面的一维信号中,频率大约是4Hz,假设采样率是50ms。

这怎么能通过编程的方式从数据中提取出来呢?

p>

10
2
1
2
8
10
8
2
1
1
8
10
7
1
1
2
7
10
5
1

解决方案

使用自动关联功能!

将采样率转换为赫兹

fs = 1 /(50/1000)%result = 20hz

vector = [10 2 1 2 8 10 8 2 1 1 8 10 7 1 1 2 7 10 5 1];

R = xcorr(vector);

[pks,locs] = findpeaks(R);

%导致​​赫兹

fs./(diff(locs))

ans =

3.3333 4.0000 3.3333 3.3333 4.0000 3.3333

max(fs./diff(locs))

ans =

4




  • 应用自相关的信号,你可以在网上找到很多
    的源代码,用不同的语言来做自相关,一个伪代码:

      TotalSamples = length(signal)
    for z = 1:TotalSamples
    sum = 0;

    for i = 1:TotalSamples

    sum = sum +(signal(i)* signal(i + pos));

    end

    Xcorre(z)= Xcorre(z)+ sum;
    end


  • 从自相关结果中找出所有局部峰值


  • 计算局部峰值之间的差异 locs [k + 1] - locs [k]


  • 将帧频除以局部峰值之间的差值


  • 频率是最大值



Is there a simple way to extract the main frequency/period from a signal (without resorting to the FFT)?

For my requirements, this can result in either a value for the main frequency (e.g. 3Hz) or a value representing the strength of a target frequency. For example, in the following 1-D signal the frequency is about 4Hz, assuming the sampling rate is 50ms.

How can this be extracted from the data programmatically?

10 2 1 2 8 10 8 2 1 1 8 10 7 1 1 2 7 10 5 1

解决方案

Use Auto Correlation !

%using Matlab

%convert sample rate to hertz

fs = 1/(50/1000) % result = 20hz

vector = [10 2 1 2 8 10 8 2 1 1 8 10 7 1 1 2 7 10 5 1];

R = xcorr(vector);

[pks,locs]=findpeaks(R);

%result in hertz

fs./(diff(locs))

ans =

3.3333    4.0000    3.3333    3.3333    4.0000    3.3333

max(fs./diff(locs))

ans =

4

  • Apply Autocorrelation on the signal, you can find a lot of source code in the web in defferent languages to do autocorrelation, a pseudo code:

    TotalSamples = length(signal)
    for z=1:TotalSamples
     sum = 0;
    
     for i=1:TotalSamples
    
               sum = sum + (signal(i)*signal(i + pos));
    
     end
    
     Xcorre(z) = Xcorre(z) + sum;
    end
    

  • Find all local peaks from result of autocorrelation

  • Compute the difference between local peaks locs[k+1] - locs[k]

  • Divide your frame rate by the difference between local peaks

  • The Frequency is the Maximum value

这篇关于如何从信号中提取频率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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