在不使用内置函数的情况下,在matlab中进行互相关? [英] Cross-correlation in matlab without using the inbuilt function?

查看:238
本文介绍了在不使用内置函数的情况下,在matlab中进行互相关?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能说出如何在不使用内置函数xcorr和相关系数的情况下在MATLAB中对两个语音信号(每个40,000个样本)进行互相关吗?

can someone tell how to do the cross-correlation of two speech signals (each of 40,000 samples) in MATLAB without using the built-in function xcorr and the correlation coefficient?

谢谢.

推荐答案

您可以使用fft进行互相关.两个向量的互相关只是它们各自的傅立叶变换的产物,其中一个是共轭的.

You can do cross-correlations using fft. The cross-correlation of two vectors is simply the product of their respective Fourier transforms, with one of the transforms conjugated.

a=rand(5,1);
b=rand(5,1);
corrLength=length(a)+length(b)-1;

c=fftshift(ifft(fft(a,corrLength).*conj(fft(b,corrLength))));

比较结果:

c =

    0.3311
    0.5992
    1.1320
    1.5853
    1.5848
    1.1745
    0.8500
    0.4727
    0.0915

>> xcorr(a,b)

ans =

    0.3311
    0.5992
    1.1320
    1.5853
    1.5848
    1.1745
    0.8500
    0.4727
    0.0915

这篇关于在不使用内置函数的情况下,在matlab中进行互相关?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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