1、adsp仿真作业DSP仿真实验一实验题目:Generate a stationary process AR(2) denoted by. Suppose that Here, the parameters of are determined by yourselves. Then generate a white noise with the variance. The received signal iswith a variable SNR. Put the received the signal to a Wiener-filter, the length of the filter i
2、s N. And the output is denoted by.Study on the relationship between the cost function and SNR of the signal, provided the length of the Wiener-filter is given.Study on the relationship between the cost function and length of the filter, provided the SNR is given.3. When one-step prediction is done,
3、how about the cost function varies with the SNR and length of the Wiener-filter.二实验原理和方法本仿真实验主要运用Wiener-Hopf方程, 该Wiener-Hopf方程为: 亦可简写为: 通过求逆得: 其中:为输入滤波器的序列的自相关矩阵,是与的互相关函数。计算时,运用公式: 本仿真实验通过选取,利用迭代产生(阶数为),并随机产生(阶数也为),可以计算得到。然后计算信噪比,采用如下公式:,其中,。接着构造长度为N的Wiener滤波器,通过生成输入滤波器的序列的自相关矩阵,求得与的互相关函数(),然后再利用Wie
4、ner-Hopf方程求出,由Wiener滤波器对进行滤波处理,得到相应的,计算代价函数。三源代码 % - clc; clear; Var_V=1.0;% Var_V-加性噪声V的标准差 M=10000;% M-产生的信号的长度 N=8;% N-Wiener滤波器的长度 Var_W=0.8;% 产生发射信号S(n),取a1=0.195,a2=-0.95 randn(state,0); W=sqrt(Var_W)*randn(1,M); % W-用于在AR模型中产生信号S(n)的白噪声 a1=0.195; a2=-0.95; S=zeros(1,M);% S-信号的时间序列模型 S(1)=W(1)
5、; S(2)=W(2); for n=3:M; S(n)=a1*S(n-1)+a2*S(n-2)+W(n); end; figure(1); n=1:M; subplot(2,1,1) stem(n,S); title(发射的信号S(n); xlabel(n); ylabel(S(n);% 产生X(n) randn(state,1); V= Var_V*randn(1,M);% V-S(n)经传输后加入的噪声 X(n)=S(n)+V(n);% X(n)-发射信号加入噪声后的接收到的信号,即输入Wiener滤波器的信号 subplot(2,1,2); n=1:M; stem(n,X(n); ti
6、tle(接收到的加噪声之后的信号X(n); xlabel(n); ylabel(X(n);% 计算信噪比 SNR S_Power=mean(S.2); N_Power=mean(V.2); SNR=10*log10(abs(S_Power/N_Power);% SNR-信噪比 % 构造长度为N的Wiener滤波器 r=zeros(1,N+1); for n=0:N; temp=0; for c=(n+1):M; temp=temp+X(c)*X(c-n); end; r(n+1)=(1/M)*temp; temp=0; end; R=zeros(N,N);% R-信号X(n)的自相关矩阵,维数
7、为(N-1)*(N-1) R(1,:)=r(1:N); for row=2:N; R(row,1)=r(row); R(row,2:N)=R(row-1,1:N-1); end; P=zeros(1,N);% P-X(n)与S(n)的互相关 X_temp=X; for k=0:N-1; X_temp(1:M-k)=X(1+k:M); X_temp(M-k+1:M)=0; P(k+1)=1/M*X_temp*S; end; Wo=zeros(1,N); Wo=inv(R)*P; Wo=Wo; % 由Wiener滤波器进行滤波处理,得到Y(n) Y_temp=conv(Wo,X); Y=Y_tem
8、p(1:M); % 计算代价函数J E=zeros(1,M); E=S-Y; J=mean(E.2); % J-代价函数; disp(J=); disp(J); disp(SNR=); disp(SNR); % 一步线性预测 N_P=N; A_P=zeros(N_P); r_p=zeros(1,N_P); r_p=r(2:N+1); A_P=A_P; A_P=inv(R)*(r_p) Y_P_temp=conv(A_P,X); Y_P=zeros(1,M); Y_P(3:M)=Y_P_temp(1:M-2); % 计算J_P E_P=zeros(1,M); E_P=S-Y_P; J_P=mea
9、n(E_P.2); disp(J_P=); disp(J_P); % figure(2) % stem(Y_P);四实验结果分析1. 当N=8,Var_W=0.8时,通过改变Var_V的值得到下表: Var_V SNR J 0.1 28.9066 0.0098 0.2 22.8860 0.0379 0.4 16.8654 0.1358 0.6 13.3435 0.2674 0.8 10.8448 0.4151 1.0 8.9066 0.5703 1.2 7.3229 0.7293 1.4 5.9840 0.8906 1.6 4.8242 1.0540通过输入以下程序段:SNR=28.9066
10、22.8860 16.8654 13.3435 10.8448 8.9066 7.3229 5.9840 4.8242;J=0.0098 0.0379 0.1358 0.2674 0.4151 0.5703 0.7293 0.8906 1.0540;plot(SNR,J);title(The Relationship between SNR and J(N=8);xlabel(SNR(dB);ylabel(J);可以得到如下图形:由上面的曲线可以看出: 随着输入信噪比的增大,代价函数逐渐变小。根据代价函数计算式可以得出这是一个很显然的事实。2. Var_V=0.6,Var_W=0.8,SNR=
11、 13.3435 dB,通过改变N的值得到下表: N J 1 0.3407 2 0.3406 3 0.2713 4 0.2709 5 0.2674 6 0.2673 7 0.2673 8 0.2674 9 0.2674 10 0.2674通过输入以下程序段:N=1 2 3 4 5 6 7 8 9 10;J=0.3407 0.3406 0.2713 0.2709 0.2674 0.2673 0.2673 0.2674 0.2674 0.2674;stem(N,J);title(The Relationship between J and N(SNR=13.3435 dB);xlabel(N);y
12、label(J);可以得到如下图形:由上面的曲线可以看出: 随着Wiener滤波器的长度的增加, 代价函数先是逐渐减小,到时逐渐趋于平稳。 这说明单靠增加Wiener滤波器的长度来提高滤波器性能的方法是行不通的。3. (1) N=8,Var_W=0.8,通过改变Var_V的值得到下表: Var_V SNR J 0.1 28.9066 13.4095 0.2 22.8860 13.3836 0.4 16.8654 13.2987 0.6 13.3435 13.1941 0.8 10.8448 13.0839 1.0 8.9066 12.9725 1.2 7.3229 12.8600 1.4 5.
13、9840 12.7455 1.6 4.8242 12.6280通过输入以下程序段:SNR=28.9066 22.8860 16.8654 13.3435 10.8448 8.9066 7.3229 5.9840 4.8242;J_P=13.4095 13.3836 13.2987 13.1941 13.0839 12.9725 12.8600 12.7455 12.6280;plot(SNR,J_P);title(The Relationship between SNR and J_P(N=8);xlabel(SNR(dB);ylabel(J_P);可以得到如下图形: 由上面的曲线可以看出:
14、随着加性噪声V的标准差Var_V的增大, 输入信噪比和代价函数都随之减小,这与实际要求的结果有一定的差距。(2) Var_V=0.6,Var_W=0.8,SNR= 13.3435 dB,通过改变N的值得到下表: N J 1 9.1634 2 13.0995 3 13.1606 4 13.1907 5 13.1940 6 13.1942 7 13.1938 8 13.1941 9 13.1941 10 13.1942通过输入以下程序段:N=1 2 3 4 5 6 7 8 9 10;J_P=9.1634 13.0995 13.1606 13.1907 13.1940 13.1942 13.1938 13.1941 13.1941 13.1942;stem(N,J_P);title(The Relationship between J_P and N(SNR=6.4921dB);xlabel(N);ylabel(J_P);可以得到如下图形:由上面的曲线可以看出: 随着Wiener滤波器的长度的增加, 代价函数先是逐渐增大, 到时趋于平稳。这说明单靠增加Wiener滤波器的长度来减小代价函数的方法是行不通的。
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1