《测量与信号基础英文PPT (23).pdf》由会员分享,可在线阅读,更多相关《测量与信号基础英文PPT (23).pdf(19页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、Chapter 5 Time delay Correlation Analysis Fundamentals of Measurement and Signal Analysis 5.3 Calculation of correlation function 1.Digital Algorithm Cross-correlation function:()()()xyRx t y tdtDiscrete formula for digital signals:()()();0Rkx n y knxyNkk 0;1;2;.k*t/K Fs5.3 Calculation of correlatio
2、n function Fs=1024;dt=1.0/Fs;DF=0;T=1;N=T/dt;x=linspace(0,T,N);y1=2*sin(2*3.14*5*x);y2=2*cos(2*3.14*5*x);subplot(3,1,1);plot(x,y1,b,linewidth,1);xlim(0,T);ylim(-2,2);grid on;subplot(3,1,2);plot(x,y2,b,linewidth,1);xlim(0,T);ylim(-2,2);grid on;for k=1:N/2 z0=0;z1(k)=0;z2(k)=0;for j=1:N z0=z0+y1(j)*y2
3、(j);end z0=z0/N;for j=1:N-k z1(k)=z1(k)+y1(j)*y2(j+k);end z1(k)=z1(k)/(N-k);for j=k:N z2(k)=z2(k)+y1(j)*y2(j-k+1);end z2(k)=z2(k)/(N-k);end zz=z2 z0 z1;N2=length(zz);x2=linspace(-T/2,T/2,N2);subplot(3,1,3);plot(x2,zz,r,linewidth,1);ylim(-2,2);grid on;Digital formula:()()();0Rkx n y knxyNkDisadvantag
4、es:Double FOR Loops,large amount of calculation.x t()y t()xyR()5.3 Calculation of correlation function 2.FFT Algorithm xyRcorr x yP fX f Yf*()(,)()()()The Fourier transform of the correlation is the product of the Fourier transform of one function by the complex conjugate of the Fourier transform of
5、 another.So,we can have a FT based algorithm xyRFP f1()()Rxy=ifft(fft(x).*conj(fft(y)fF x tX()();fF y tY()();P fX f Yf*()()()5.3 Calculation of correlation function X 1 2 3 4 Y 1 2 3 4 Y 1 2 3 4 Y 1 2 3 4 Y 1 2 3 4 Y 1 2 3 4 Y 1 2 3 4 Y 1 2 3 4 Rxy=04 11 20 30 20 11 04 Direct Algorithm Problems caus
6、ed by the periodic extension X.1 2 3 4 1 2 3 4 1 2 3 4.x=1 2 3 4;y=1 2 3 4;Rxy1=ifft(fft(x).*conj(fft(y);Rxy=30 24 22 24 30 24 22 Y 1 2 3 4 Y 1 2 3 4 Y 1 2 3 4 Y 1 2 3 4 FFT based Algorithm X 2024-45.3 Calculation of correlation function Solution:Add zeros to avoid the overlap of periodic extension.
7、X.0 0 0 0 1 2 3 4 0 0 0 0 1 2 3 4 0 0 0 0.Y 1 2 3 4 0 0 0 0 Y 1 2 3 4 0 0 0 0 Y 1 2 3 4 0 0 0 0 Y 1 2 3 4 0 0 0 0 Y 1 2 3 4 0 0 0 0 Y 1 2 3 4 0 0 0 0 Y 1 2 3 4 0 0 0 0 Rxy=04 11 20 30 20 11 04 x=1 2 3 4;y=1 2 3 4;x1=x zeros(1,4)y1=y zeros(1,4)Rxy2=ifft(fft(x1).*conj(fft(y1)Rxy3=fftshift(Rxy2)x1=1 2
8、3 4 0 0 0 0 y1=1 2 3 4 0 0 0 0 Rxy2=30 20 11 4 0 4 11 20 Rxy3=0 4 11 20 30 20 11 4 IFFT xcorr API of MATLAB:x(n)X(n)y(n)Y(n)FFT FFT R(n)=X(n)*Y(n)R(n)r(n)N1=length(x);N2=length(y);x1=x zeros(1,N1);y1=y zeros(1,N2);Rxy2=ifft(fft(x1).*conj(fft(y1);Rxy3=fftshift(Rxy2);5.3 Calculation of correlation fun
9、ction New problem:the correlation function curve is decaying,which is different from the real result!Fs=5120;N=1024;dt=1.0/Fs;T=dt*N;t=linspace(0,T,N);x=sin(2*3.14*50*t);subplot(2,1,1);plot(t,x,linewidth,2);grid on;r=xcorr(x);N1=length(r);t1=linspace(-T,T,N1);subplot(2,1,2);plot(t1,r,linewidth,2);gr
10、id on;5.3 Calculation of correlation function x t()xR()0 T-T 0 T Period extension Overlapping distortion!The problem is caused by period extension:5.3 Calculation of correlation function +Period extension Overlapping distortion!The problem is caused by period extension:5.3 Calculation of correlation
11、 function Improved period extension:5.3 Calculation of correlation function Integral of the overlapping area=0 +Improved period extension:5.3 Calculation of correlation function 0 T/2 T 5.3 Calculation of correlation function The Auto-correlation function is always a decayed curve:0 T/2 T/2wT-Unbias
12、ed:uR()R()/xwSolution:unbiased Fs=5120;N=1024;dt=1.0/Fs;T=dt*N;t=linspace(0,T,N);x=sin(2*3.14*50*t);subplot(3,1,1);plot(t,x,linewidth,2);grid on;r=xcorr(x);N1=length(r);t1=linspace(-T,T,N1);subplot(3,1,2);plot(t1,r,linewidth,2);grid on;r1=xcorr(x,unbiased);subplot(3,1,3);plot(t1,r1,linewidth,2);grid
13、 on;5.3 Calculation of correlation function x t()xR()0 T-T 0 T xR()uR()R()/xwSolution:unbiased Fs=5120;N=1024;dt=1.0/Fs;T=dt*N;t=linspace(0,T,N);x=2*randn(1,N);subplot(3,1,1);plot(t,x,linewidth,2);grid on;r=xcorr(x);N1=length(r);t1=linspace(-T,T,N1);subplot(3,1,2);plot(t1,r,linewidth,2);grid on;r1=x
14、corr(x,unbiased);subplot(3,1,3);plot(t1,r1,linewidth,2);grid on;5.3 Calculation of correlation function x t()xR()0 T-T 0 T xR()Low Confidence uR()R()/xw5.3 Calculation of correlation function Example:Auto-correlation function of echo signal FileName,PathName=uigetfile(*.*,Select File);abc=fullfile(P
15、athName,FileName);y,Fs=audioread(abc);N=length(y);dt=1.0/Fs;T=N*dt;t=linspace(0,T,N);subplot(2,1,1);plot(t,y,LineWidth,2);grid on;s=xcorr(y,unbiased);N1=length(s)t1=linspace(-T,T,N1);subplot(2,1,2);plot(t1,s,LineWidth,2);grid on;x t()xR()xlim(2,2.1);5.3 Calculation of correlation function Example:Cr
16、oss-correlation function of two sine signals Fs=500;dt=1.0/Fs;T=1;N=T/dt;x=linspace(0,T,N);y1=2*sin(2*3.14*5*x);y2=2*cos(2*3.14*10*x);subplot(3,1,1);plot(x,y1,linewidth,2);xlim(0,T);ylim(-2,2);grid on;subplot(3,1,2);plot(x,y2,linewidth,2);xlim(0,T);ylim(-2,2);grid on;s1=xcorr(y1,y2,unbiased);N1=leng
17、th(s1);x1=linspace(-T,T,N1);subplot(3,1,3);plot(x1,s1,r,linewidth,2);xlim(-T/2,T/2);ylim(-2,2);grid on;x t()ty()xyR()Homeworks 5.3 Calculation of correlation function 1.Design a GUI program to show the auto-correlation function and cross-correlation function of standard signals,and to prove properties of correlation function.Fundamentals of Measurement and Signal Analysis