求大神解释这段matlab程序,我基础不是很好,希望能够帮助我,clear alln=99; T=6; t=0:2*pi/(n-1):2*T*pi; N=length(t);fs=1/(n-1);x1=4*sin(t); y1=4*sin(t+pi/6); x=awgn(x1,20); y=awgn(y1,0.001);x2=awgn(x1./4,-3); subplot(311),plot(t,x)su
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/30 08:20:16
求大神解释这段matlab程序,我基础不是很好,希望能够帮助我,clear alln=99; T=6; t=0:2*pi/(n-1):2*T*pi; N=length(t);fs=1/(n-1);x1=4*sin(t); y1=4*sin(t+pi/6); x=awgn(x1,20); y=awgn(y1,0.001);x2=awgn(x1./4,-3); subplot(311),plot(t,x)su
求大神解释这段matlab程序,
我基础不是很好,希望能够帮助我,
clear all
n=99;
T=6;
t=0:2*pi/(n-1):2*T*pi;
N=length(t);
fs=1/(n-1);
x1=4*sin(t);
y1=4*sin(t+pi/6);
x=awgn(x1,20);
y=awgn(y1,0.001);
x2=awgn(x1./4,-3);
subplot(311),plot(t,x)
subplot(312),plot(t,y)
tic
[Cc,r]=xcorr(x,y);
[Cc1,r1]=xcorr(x1,y1);
subplot(313),plot(r*2*pi/(n-1),Cc,'r'),hold on;
plot(Cc1,'-');
tic
S1=fft(x,2*N-1);
S2=fft(y,2*N-1);
X=S1.* conj(S2);
R1=real(fftshift(ifft(X)));
toc
figure(2)
subplot(211),plot(Cc),title('xcorr')
subplot(212),plot(R1);
title('ifft')
figure(3)
plot(xcorr(x2,'unbiased'));
求大神解释这段matlab程序,我基础不是很好,希望能够帮助我,clear alln=99; T=6; t=0:2*pi/(n-1):2*T*pi; N=length(t);fs=1/(n-1);x1=4*sin(t); y1=4*sin(t+pi/6); x=awgn(x1,20); y=awgn(y1,0.001);x2=awgn(x1./4,-3); subplot(311),plot(t,x)su
%就是对同一源信号想x1作延迟x2并加上噪声,然后用两种方法分析得到x1和x2的
%互相关函数!并对加噪声的x1 分析了自相关函数
clear all
n=99;
T=6;
t=0:2*pi/(n-1):2*T*pi;
N=length(t);
fs=1/(n-1);
x1=4*sin(t); %源信号
y1=4*sin(t+pi/6); %%源信号延迟pi/6相位
x=awgn(x1,20); %加高斯白噪声,信噪比SNR==20dB
y=awgn(y1,0.001); %同上
x2=awgn(x1./4,-3);
subplot(311),plot(t,x)
subplot(312),plot(t,y)
tic %tic和toc一起用于计算程序运算时间
[Cc,r]=xcorr(x,y); %xcorr用于求互相关矩阵函数,Cc为互相关矩阵,r为延迟矢量
[Cc1,r1]=xcorr(x1,y1); %同上
subplot(313),plot(r*2*pi/(n-1),Cc,'r'),hold on;
plot(Cc1,'-');
tic
S1=fft(x,2*N-1); %求x的2*N-1点fft
S2=fft(y,2*N-1);
X=S1.* conj(S2); %求x和y的互功率谱
R1=real(fftshift(ifft(X)));%利用ifft求反变换得到互相关函数,用fftshift反转
toc %对应tic求计算时间
figure(2)
subplot(211),plot(Cc),title('xcorr')
subplot(212),plot(R1);
title('ifft')
figure(3)
plot(xcorr(x2,'unbiased')); %求x2的自相关函数并作图