?? tsh.m
字號:
%x(t)=sing(2*pi*f*t),y=0.5*sing(2*pi*f*t+pi/2),f=10Hz,求互相關(guān)
clf
N=1000;n=0:N-1;Fs=500;t=n/Fs;
Lag=200; %最大延遲單位數(shù)
x1=90*sinc(pi*(n-0.1*Fs)); %第一個原始信號延遲0.1s
y1=50*sinc(pi*(n-0.3*Fs)); %延遲0.3s
[c,lags]=xcorr(x1,y1,Lag,'unbiased'); %計算兩個函數(shù)的互相關(guān)
subplot(2,1,1),plot(t,x1,'r'); %第一個信號
hold on;plot(t,y1,'b:'); %在同一幅圖中繪制第二個信號
legend('信號 x','信號 y'); %繪制圖例
xlabel('時間/s');ylabel('x(t) y(t)')
title('信號x和y');hold off
subplot(2,1,2),plot(lags/Fs,c,'r'); %繪制互相關(guān)信號
xlabel('時間/s');ylabel('Rxy(t)');
title('信號x和y的相關(guān)');
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -