武汉大学数字信号实验.docx
《武汉大学数字信号实验.docx》由会员分享,可在线阅读,更多相关《武汉大学数字信号实验.docx(24页珍藏版)》请在冰豆网上搜索。
武汉大学数字信号实验
姓名:
全权学号:
班级:
信安四班日期:
5月8日
实验2离散时间系统-时域分析
实验内容:
2.1SIMULATIONOFDISCRETE-TIMESYSTEMS
Project2.1TheMovingAverageSystem(挪动平均值系统)
AcopyofProgramP2_1isgivenbelow:
%ProgramP2_1
%SimulationofanM-pointMovingAverageFilter
%Generatetheinputsignal
n=0:
100;
s1=cos(2*pi*0.05*n);%Alow-frequencysinusoid
s2=cos(2*pi*0.47*n);%Ahighfrequencysinusoid
x=s1+s2;
%Implementationofthemovingaveragefilter
M=input('InputDesiredlengthofthefilter=');
num=ones(1,M);
y=filter(num,1,x)/M;
%注:
上式用滤波函数实现挪动平均
%当M=2时,y=(x(n)+x(n-1))/M
%当M=3时,y=(x(n)+x(n-1)+x(n-2))/M
%Displaytheinputandoutputsignals
clf;
subplot(2,2,1);
plot(n,s1);
axis([0,100,-2,2]);
xlabel('Timeindexn');ylabel('Amplitude');
title('Signal#1');
subplot(2,2,2);
plot(n,s2);
axis([0,100,-2,2]);
xlabel('Timeindexn');ylabel('Amplitude');
title('Signal#2');
subplot(2,2,3);
plot(n,x);
axis([0,100,-2,2]);
xlabel('Timeindexn');ylabel('Amplitude');
title('InputSignal');
subplot(2,2,4);
plot(n,y);
axis([0,100,-2,2]);
xlabel('Timeindexn');ylabel('Amplitude');
title('OutputSignal');
axis;
Answers:
Q2.1TheoutputsequencegeneratedbyrunningtheaboveprogramforM=2withx[n]=s1[n]+s2[n]astheinputisshownbelow.
s2=cos(2*pi*0.47*n);%Ahighfrequencysinusoid
Thecomponentoftheinputx[n]suppressed〔抑制〕bythediscrete-timesystemsimulatedbythisprogramis-
s2=cos(2*pi*0.47*n);%Ahighfrequencysinusoid
Q2.2ProgramP2_1ismodifiedtosimulatetheLTIsystemy[n]=0.5(x[n]–x[n–1])andprocesstheinputx[n]=s1[n]+s2[n]resultingintheoutputsequenceshownbelow:
%ProgramP2_1
%SimulationofanM-pointMovingAverageFilter
%Generatetheinputsignal
n=0:
100;
s1=cos(2*pi*0.05*n);%Alow-frequencysinusoid
s2=cos(2*pi*0.47*n);%Ahighfrequencysinusoid
x=s1+s2;
%Implementationofthemovingaveragefilter
M=input('InputDesiredlengthofthefilter=');
%num=ones(1,M);
num=(-1).^[0:
M-1];
y=filter(num,1,x)/M;
%注:
上式用滤波函数实现挪动平均
%当M=2时,y=(x(n)+x(n-1))/M
%当M=3时,y=(x(n)+x(n-1)+x(n-2))/M
%Displaytheinputandoutputsignals
clf;
subplot(2,2,1);
plot(n,s1);
axis([0,100,-2,2]);
xlabel('Timeindexn');ylabel('Amplitude');
title('Signal#1');
subplot(2,2,2);
plot(n,s2);
axis([0,100,-2,2]);
xlabel('Timeindexn');ylabel('Amplitude');
title('Signal#2');
subplot(2,2,3);
plot(n,x);
axis([0,100,-2,2]);
xlabel('Timeindexn');ylabel('Amplitude');
title('InputSignal');
subplot(2,2,4);
plot(n,y);
axis([0,100,-2,2]);
xlabel('Timeindexn');ylabel('Amplitude');
title('OutputSignal');
axis;
TheeffectofchangingtheLTIsystemontheinputis-过滤掉高频信号留下低频信号
Q2.3ProgramP2_1isrunforthefollowingvaluesoffilter〔滤波器〕lengthMandfollowingvaluesofthefrequenciesofthesinusoidalsignalss1[n]ands2[n].TheoutputgeneratedforthesedifferentvaluesofMandthefrequenciesareshownbelow.Fromtheseplotswemakethefollowingobservations-f1=0.05;f2=0.47;M=15
Project2.2(Optional)ASimpleNonlinearDiscrete-TimeSystem
AcopyofProgramP2_2isgivenbelow:
%ProgramP2_2
%Generateasinusoidalinputsignal
clf;
n=0:
200;
x=cos(2*pi*0.05*n);
%Computetheoutputsignal
x1=[x00];%x1[n]=x[n+1]
x2=[0x0];%x2[n]=x[n]
x3=[00x];%x3[n]=x[n-1]
y=x2.*x2-x1.*x3;
y=y(2:
202);
%Plottheinputandoutputsignals
subplot(2,1,1)
plot(n,x)
xlabel('Timeindexn');ylabel('Amplitude');
title('InputSignal')
subplot(2,1,2)
plot(n,y)
xlabel('Timeindexn');ylabel('Amplitude');
title('Outputsignal');
Answers:
Q2.4Thesinusoidalsignalswiththefollowingfrequenciesastheinputsignalswereusedtogeneratetheoutputsignals:
n=0:
100;
a=pi/2/100;
b=0;
arg=a*n.*n+b*n;
x=cos(arg);
M=input('Desiredlengthofthefilter=');
num=ones(1,M);
y=filter(num,1,x)/M;
clf;
subplot(2,1,1);
plot(n,x);
axis([0,100,-1.5,1.5]);
xlabel('Timeindexn');
ylabel('Amplitude');
title('inputsignal');
subplot(2,1,2);
plot(n,y);
axis([0,100,-1.5,-1.5]);
xlabel('Timeindexn');
ylabel('Amplitude');
title('inputsignal');
axis;
Theoutputsignalsgeneratedforeachoftheaboveinputsignalsaredisplayedbelow:
Theoutputsignalsdependonthefrequenciesoftheinputsignalaccordingtothefollowingrules:
Thisobservationcanbeexplainedmathematicallyasfollows:
Project2.3LinearandNonlinearSystems(线性和非线性系统)
AcopyofProgramP2_3isgivenbelow:
%ProgramP2_3
%Generatetheinputsequences
clf;
n=0:
40;
a=2;b=-3;
x1=cos(2*pi*0.1*n);
x2=cos(2*pi*0.4*n);
x=a*x1+b*x2;
num=[2.24032.49082.2403];
den=[1-0.40.75];
ic=[00];%Setzeroinitialconditions
y1=filter(num,den,x1,ic);%Computetheoutputy1[n]
y2=filter(num,den,x2,ic);%Computetheoutputy2[n]
y=filter(num,den,x,ic);%Computetheoutputy[n]
yt=a*y1+b*y2;
d=y-yt;%Computethedifferenceoutputd[n]
%Plottheoutputsandthedifferencesignal
subplot(3,1,1)
stem(n,y);
ylabel('Amplitude');
title('OutputDuetoWeightedInput:
a\cdotx_{1}[n]+b\cdotx_{2}[n]');
subplot(3,1,2)
stem(n,yt);
ylabel('Amplitude');
title('WeightedOutput:
a\cdoty_{1}[n]+b\cdoty_{2}[n]');
subplot(3,1,3)
stem(n,d);
xlabel('Timeindexn');ylabel('Amplitude');
title('DifferenceSignal');
Answers:
Q2.5Theoutputsy[n],obtainedwithweighted(加权的)input,andyt[n],obtainedbycombiningthetwooutputsy1[n]andy2[n]withthesameweights,areshownbelowalongwiththedifferencebetweenthetwosignals:
Thetwosequencesare-数字取舍后一样
Thesystemis-线性
Q2.6ProgramP2_3wasrunforthefollowingthreedifferentsetsofvaluesoftheweightingconstants(常数),aandb,andthefollowingthreedifferentsetsofinputfrequencies:
Theplotsgeneratedforeachoftheabovethreecasesareshownbelow:
Basedontheseplotswecanconcludethatthesystemwithdifferentweightsis-_线性__
Q2.7ProgramP2_3wasmodifiedtosimulatethesystem:
y[n]=x[n]x[n–1]
Theoutputsequencesy1[n],y2[n],andy[n]oftheabovesystemgeneratedbyrunningthemodifiedprogramareshownbelow:
Comparingy[n]withyt[n]weconcludethatthetwosequencesare-_不同____
Thissystemis-_非线性
Project2.4Time-invariant(时不变)andTime-varying(时变)Systems
AcopyofProgramP2_4isgivenbelow:
%ProgramP2_4
%Generatetheinputsequences
clf;
n=0:
40;D=10;a=3.0;b=-2;
x=a*cos(2*pi*0.1*n)+b*cos(2*pi*0.4*n);
xd=[zeros(1,D)x];
num=[2.24032.49082.2403];
den=[1-0.40.75];
ic=[00];%Setinitialconditions
%Computetheoutputy[n]
y=filter(num,den,x,ic);
%Computetheoutputyd[n]
yd=filter(num,den,xd,ic);
%Computethedifferenceoutputd[n]
d=y-yd(1+D:
41+D);
%Plottheoutputs
subplot(3,1,1)
stem(n,y);
ylabel('Amplitude');
title('Outputy[n]');grid;
subplot(3,1,2)
stem(n,yd(1:
41));
ylabel('Amplitude');
title(['OutputduetoDelayedInputx[n-',num2str(D),']']);grid;
subplot(3,1,3)
stem(n,d);
xlabel('Timeindexn');ylabel('Amplitude');
title('DifferenceSignal');grid;
Answers:
Q2.8Theoutputsequencesy[n]andyd[n-10]generatedbyrunningProgramP2_4areshownbelow-
Thesetwosequencesarerelatedasfollows-
Thesystemis-___时不变系统_
Q2.9Theoutputsequencesy[n]andyd[n-D]generatedbyrunningProgramP2_4forthefollowingvaluesofthedelayvariableD-
areshownbelow-____________
Ineachcase,thesetwosequencesarerelatedasfollows-
Thesystemis-__时不变系统
2.2LINEARTIME-INVARIANTDISCRETE-TIMESYSTEMS
Project2.5ComputationofImpulseResponses(冲击响应)ofLTISystems
AcopyofProgramP2_5isshownbelow:
Answers:
Q2.10Thefirst41samplesoftheimpulseresponseofthediscrete-timesystemofProject2.3generatedbyrunningProgramP2_5isgivenbelow:
%ProgramP2_5
%Computetheimpulseresponsey
clf;
N=40;
num=[2.24032.49082.2403];
den=[1-0.40.75];
y=impz(num,den,N);
%Plottheimpulseresponse
stem(y);
xlabel('Timeindexn');ylabel('Amplitude');
title('ImpulseResponse');grid;
Q2.11TherequiredmodificationstoProgramP2_5togeneratetheimpulseresponseofthefollowingcausalLTIsystem:
y[n]+0.71y[n-1]–0.46y[n-2]–0.62y[n-3]
=0.9x[n]–0.45x[n-1]+0.35x[n-2]+0.002x[n-3]
aregivenbelow:
clf;
N=45;
num=[0.9-0.450.350.002];
den=[1.00.71-0.46-0.62];
y=impz(num,den,N);
stem(y);
xlabel('Timeindexn');ylabel('Amplitude');
title('ImpulseResponse');grid;
Thefirst45samplesoftheimpulseresponseofthisdiscrete-timesystemgeneratedbyrunningthemodifiedisgivenbelow: