Ask an expert. Trust the answer.

Your academic and career questions answered by verified experts

How to Cross-correlation in matlab without using the inbuilt function?

Date: 2022-08-02 10:58:29

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?

Thanks in advance. 

Answers: 

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.

Example: 

 

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

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

Compare results: 

 

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 

 


Why Matlabhelpers ?

Our Matlab assignment helpers for online MATLAB assignment help service take utmost care of your assignments by keeping the codes simple yet of high-quality. We offer the most reliable MATLAB solutions to students pursuing their Computer Science course from the Monash University, the University of Sydney, the University of New South Wales, the University of Melbourne; to name a few. Approach us today for best Matlab solutions online!

whatsApp order on matlabhelpers.com

telegram order on matlabsolutions.com