宁波大学数字信号处理实验一.docx
- 文档编号:5953514
- 上传时间:2023-01-02
- 格式:DOCX
- 页数:12
- 大小:201.66KB
宁波大学数字信号处理实验一.docx
《宁波大学数字信号处理实验一.docx》由会员分享,可在线阅读,更多相关《宁波大学数字信号处理实验一.docx(12页珍藏版)》请在冰豆网上搜索。
宁波大学数字信号处理实验一
Experiment1
周焕强116040268
Project1IllustrationofEnsembleAveraging
R=50;
m=0:
R-1;
s=2*m.*(0.9.^m);%产生未受干扰序列
d=rand(R,1)-0.5;%产生噪声
x1=0;
forn=1:
R;
d=rand(R,1)-0.5;
x1=x1+d;%将噪声加到原序列上
end
x1=x1/R;
subplot(2,2,1);stem(m,s);
title('原始未干扰的数据');xlabel('时间序号n');ylabel('振幅');
subplot(2,2,2);stem(m,d);
title('噪声');xlabel('时间序号n');ylabel('振幅');
subplot(2,2,3);stem(m,s+d');
title('受干扰序列');xlabel('时间序号n');ylabel('振幅');
subplot(2,2,4);stem(m,s+x1');
title('总体平均');xlabel('时间序号n');ylabel('振幅');
Project2Complexexponentialsequencegeneration
%ProgramP1_2_1
%Generationofcomplexexponentialsequence
a=input('Typeinrealexponent=');
b=input('Typeinimaginaryexponent=');
c=a+b*i;
K=input('Typeinthegainconstant=');
N=input('Typeinlengthofsequence=');
n=1:
N;
x=K*exp(c*n);%Generatethesequence
subplot(2,1,1);
stem(n,real(x));%Plottherealpart
xlabel('Timeindexn');ylabel('Amplitude');title('Realpart');
disp('PRESSRETURNforimaginarypart');
subplot(2,1,2);
stem(n,imag(x));%Plottheimaginarypart
xlabel('Timeindexn');ylabel('Amplitude');title('Imaginarypart');
%ProgramP1_2_2
A=input('输入系数A=');
a=input('底数a=');
N=input('输入序列长度=');
n=0:
N;
x=A*a.^n;%指数序列
stem(n,x);
xlabel('时间序列n');ylabel('振幅');
输入系数A=0.2
底数a=1.2
输入序列长度=30
输入系数A=20
底数a=0.9
输入序列长度=30
%ProgramP1_2_3
w=input('输入Wo=');
A=input('系数A=');
N=input('输入序列长度=');
n=0:
N;
x=A*cos(w.*n);%余弦序列
stem(n,x);
xlabel('时间序列n');ylabel('振幅');
输入序列长度=30
输入Wo=0
系数A=1.5
输入序列长度=40
Project3Moving-AverageFilter
%ProgramP1_3_1
R=50;
d=rand(R,1)-0.5;%产生噪声
m=0:
1:
R-1;
s=2*m.*(0.9.^m);%原序列
x=s+d';%叠加噪声
plot(m,d,'r-',m,s,'b--',m,x,'g:
')%画出噪声序列和原序列
xlabel('Timeindexn');ylabel('Amplitude');
legend('d[n]','s[n]','x[n]');
%ProgramP1_3_2
R=50;
d=rand(R,1)-0.5;
m=0:
1:
R-1;
s=2*m.*(0.9.^m);
x=s+d';
M=input('Numberofinputsamples=');
b=ones(M,1)/M;
y=filter(b,1,x);
plot(m,s,'r-',m,y,'b--')
legend('s[n]','y[n]');
xlabel('Timeindexn');ylabel('Amplitude');
Numberofinputsamples=3
%ProgramP1_3_3
R=50;
d=rand(R,1)-0.5;
m=0:
1:
R-1;
s=2*m.*(0.9.^m);
x=s+d';
M=input('Numberofinputsamples=');
x=[zeros(1,M-1),x];
fori=M:
R-1
sum=0;
forl=0:
M-1
sum=sum+x(i-l);
end
y(i)=sum/M;
end
plot(m,s,'r-',m,y,'b--')
legend('s[n]','y[n]');
xlabel('Timeindexn');ylabel('Amplitude');
Numberofinputsamples=3
Length=5
Length=7
Length=9
Thesignalsmoothingimproveswithanincreaseinthelength.
M越大,滑动滤波器输出延时越长,但是对噪声输入延时没有影响。
Project4ImpulseNoiseRemovalUsingMedianFilter
%Program1_4_12
R=50;a=rand(1,R)-0.4;
b=round(a);
m=0:
R-1;
s=2*m.*(0.9.^m);
x=s+b;
M=input('MedianFilterlength=');
y=medfilt1(x,M);
subplot(2,1,1)
stem(m,x);axis([050-18]);
xlabel('n');ylabel('Amplitude');
title('TmpulseNoiseCorruptedSignal');
subplot(2,1,2)
stem(m,y);
xlabel('n');ylabel('Amplitude');
title('OutputofMedianFilter');
MedianFilterlength=3
%Program1_4_3
R=50;
a=rand(1,R)-0.4;
b=round(a);
m=0:
R-1;
s=2*m.*(0.9.^m);
x=s+b;
M=input('Numberofinputsamples=');
x2=[zeros(1,(M-1)/2),x,zeros(1,(M-1)/2)];
fori=1:
R
c=sort(x2(i:
i+M-1));
y(i)=c((M+1)/2);
end
subplot(2,1,1);
stem(m,x);axis([050-18]);
xlabel('n');ylabel('Amplitude');
title('ImpulseNoiseCorruptedSignal');
subplot(2,1,2);
stem(m,y);
xlabel('n');ylabel('Amplitude');
title('OutputofMedianFilter');
M=5
Project6ConvolutionComputationUsingMATLAB
%Program1_6_1
%IllustrationofConvolution
a=input('Typeinthefirstsequence=');
b=input('Typeinthesecondsequence=');
c=conv(a,b);
M=length(c)-1;
n=0:
1:
M;
disp('outputsequence=');disp(c);
stem(n,c)
xlabel('Timeindexn');ylabel('Amplotude');
Typeinthefirstsequence=[-201-13]
Typeinthesecondsequence=[120-1]
outputsequence=
-2-413151-3
Typeinthefirstsequence=[-201-13]
Typeinthesecondsequence=[10000]
outputsequence=
-201-130000
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 宁波大学 数字信号 处理 实验