西安电子科技大学数字信号处理上机作业资料.docx

上传人:b****8 文档编号:8883779 上传时间:2023-02-02 格式:DOCX 页数:29 大小:473.75KB
下载 相关 举报
西安电子科技大学数字信号处理上机作业资料.docx_第1页
第1页 / 共29页
西安电子科技大学数字信号处理上机作业资料.docx_第2页
第2页 / 共29页
西安电子科技大学数字信号处理上机作业资料.docx_第3页
第3页 / 共29页
西安电子科技大学数字信号处理上机作业资料.docx_第4页
第4页 / 共29页
西安电子科技大学数字信号处理上机作业资料.docx_第5页
第5页 / 共29页
点击查看更多>>
下载资源
资源描述

西安电子科技大学数字信号处理上机作业资料.docx

《西安电子科技大学数字信号处理上机作业资料.docx》由会员分享,可在线阅读,更多相关《西安电子科技大学数字信号处理上机作业资料.docx(29页珍藏版)》请在冰豆网上搜索。

西安电子科技大学数字信号处理上机作业资料.docx

西安电子科技大学数字信号处理上机作业资料

数字信号处理MATLAB上机作业

 

M2.2

1.题目

ThesquarewaveandthesawtoothwavearetwoperiodicsequencesassketchedinfigureP2.4.Usingthefunctionstem.Theinputdataspecifiedbytheuserare:

desiredlengthLofthesequence,peakvalueA,andtheperiodN.Forthesquarewavesequenceanadditionaluser-specifiedparameteristhedutycycle,whichisthepercentoftheperiodforwhichthesignalispositive.Usingthisprogramgeneratethefirst100samplesofeachoftheabovesequenceswithasamplingrateof20kHz,apeakvalueof7,aperiodof13,andadutycycleof60%forthesquarewave.

2.程序

%用户定义各项参数参数

A=input('Thepeakvalue=');

L=input('Lengthofsequence=');

N=input('Theperiodofsequence=');

FT=input('Thedesiredsamplingfrequency=');

DC=input('Thesquarewavedutycycle=');

%产生所需要的信号

t=0:

L-1;

T=1/FT;

x=A*sawtooth(2*pi*t/N);

y=A*square(2*pi*(t/N),DC);

%Plot

subplot(2,1,1)

stem(t,x);

ylabel('幅度');

xlabel('n');

subplot(2,1,2)

stem(t,y);

ylabel('幅度');

xlabel('n');

3.结果

4.结果分析

M2.4

1.题目

(a)Writeamatlabprogramtogenerateasinusoidalsequencex[n]=Acos(ω0n+Ф)andplotthesequenceusingthestemfunction.TheinputdataspecifiedbytheuserarethedesiredlengthL,amplitudeA,theangularfrequencyω0,andthephaseФwhere0<ω0

(b)GeneratesinusoidalsequenceswiththeangularfrequenciesgiveninProblem2.22.Determinetheperiodofeachsequencefromtheplotandverifytheresulttheoretically.

2.程序

%用户定义的参数

L=input('Desiredlength=');

A=input('Amplitude=');

omega=input('Angularfrequency=');

phi=input('Phase=');

%信号产生

n=0:

L-1;

x=A*cos(omega*n+phi);

stem(n,x);

xlabel('n');ylabel('幅度');

title(['\omega_{o}=',num2str(omega)]);

3.结果

(a)

ω0=0

ω0=0.1π

ω0=0.8π

ω0=1.2π

(b)

ω0=0.14π

ω0=0.24π

ω0=0.34π

ω0=0.68π

ω0=0.75π

4.结果分析

M2.5

1.题目

Generatethesequencesofproblem2.21(b)to2.21(e)usingmatlab.

2.程序

(b)

n=0:

99;

x=sin(0.6*pi*n+0.6*pi);

stem(n,x);

xlabel('n');ylabel('幅度');

(c)

n=0:

99;

x=2*cos(1.1*pi*n-0.5*pi)+2*sin(0.7*pi*n);

stem(n,x);

xlabel('n');ylabel('幅度');

(d)

n=0:

99;

x=3*sin(1.3*pi*n-4*cos(0.3*pi*n+0.45*pi));

stem(n,x);

xlabel('n');ylabel('幅度');

(e)

n=0:

99;

x=5*sin(1.2*pi*n+0.65*pi)+4*sin(0.8*pi*n)-cos(0.8*pi*n);

stem(n,x);

xlabel('n');ylabel('幅度');

(f)

n=0:

99;

x=mod(n,6);

stem(n,x);

xlabel('n');ylabel('幅度');

3.结果

(b)

(c)

(d)

(e)

(f)

4.结果分析

M2.6

1.题目

Writeamatlabprogramtoplotacontinuous-timesinusoidalsignalanditssampledversionandverifyfigure2.19.Youneedtousetheholdfunctiontokeepbothplots.

2.程序

%用户定义的参数

fo=input('FrequencyofsinusoidinHz=');

FT=input('SampligfrequencyinHz=');

%产生信号

t=0:

0.001:

1;

g1=cos(2*pi*fo*t);

plot(t,g1,'-')

xlabel('时间t');ylabel('幅度')

hold

n=0:

1:

FT;

gs=cos(2*pi*fo*n/FT);

plot(n/FT,gs,'o');holdoff

3.结果

4.结果分析

M3.1

1.题目

Usingprogram3_1determineandplottherealandimaginarypartsandthemagnitudeandphasespectraofthefollowingDTFTforvariousvaluesofrandθ:

0

2.程序

%program3_1

%discrete-timefouriertransformcomputatition

%

k=input('Numberoffrequencypoints=');

num=input('Numeratorcoefficients=');

den=input('Denominatorcoefficients=');

%computerthefrequencyresponse

w=0:

pi/k:

pi;

h=freqz(num,den,w);

%plotthefrequencyresponse

subplot(221)

plot(w/pi,real(h));grid

title('realpart')

xlabel('\omega/\pi');ylabel('Amplitude')

subplot(222)

plot(w/pi,imag(h));grid

title('imaginarypart')

xlabel('\omega/\pi');ylabel('Amplitude')

subplot(223)

plot(w/pi,abs(h));grid

title('magnitudespectrum')

xlabel('\omega/\pi');ylabel('magnitude')

subplot(224)

plot(w/pi,angle(h));grid

title('phasespectrum')

xlabel('\omega/\pi');ylabel('phase,radians')

3.结果

(a)r=0.8θ=π/6

(b)r=0.6θ=π/3

4.结果分析

M3.4

1.题目

UsingmatlabverifythefollowinggeneralpropertiesoftheDTFTaslistedinTable3.2:

(a)Linearity,(b)time-shifting,(c)frequency-shifting,(d)differentiation-in-frequency,(e)convolution,(f)modulation,and(g)Parseval’srelation.Sincealldatainmatlabhavetobefinite-lengthvectors,thesequencestobeusedtoverifythepropertiesarethusrestrictedtobeoffinitelength.

2.程序

%先定义两个信号

N=input('Thelengthofthesequence=');

k=0:

N-1;

%g为正弦信号

g=2*sin(2*pi*k/(N/2));

%h为余弦信号

h=3*cos(2*pi*k/(N/2));

[G,w]=freqz(g,1);

[H,w]=freqz(h,1);

%*************************************************************************%

%线性性质

alpha=0.5;

beta=0.25;

y=alpha*g+beta*h;

[Y,w]=freqz(y,1);

figure

(1);

subplot(211),plot(w/pi,abs(Y));

xlabel('\omega/\pi');ylabel('|Y(e^j^\omega)|');

title('线性叠加后的频率特性');grid;

%画出Y的频率特性

subplot(212),plot(w/pi,alpha*abs(G)+beta*abs(H));

xlabel('\omega/\pi');ylabel('\alpha|G(e^j^\omega)|+\beta|H(e^j^\omega)|');

title('线性叠加前的频率特性');grid;

%画出alpha*G+beta*H的频率特性

%*************************************************************************%

%时移性质

n0=10;%时移10个的单位

y2=[zeros([1,n0])g];

[Y2,w]=freqz(y2,1);

G0=exp(-j*w*n0).*G;

figure

(2);

subplot(211),plot(w/pi,abs(G0));

xlabel('\omega/\pi');ylabel('|G0(e^j^\omega)|');

title('G0的频率特性');grid;

%画出G0的频率特性

subplot(212),plot(w/pi,abs(Y2));

xlabel('\omega/\pi');ylabel('|Y2(e^j^\omega)|');

title('Y2的频率特性');grid;

%画出Y2的频率特性

%*************************************************************************%

%频移特性

w0=pi/2;%频移pi/2

r=256;%thevalueofw0intermsofnumberofsamples

k=0:

N-1;

y3=g.*exp(j*w0*k);

[Y3,w]=freqz(y3,1);

%对采样的512个点分别进行减少pi/2,从而生成G(exp(w-w0))

k=0:

511;

w=-w0+pi*k/512;

G1=freqz(g,1,w);

figure(3);

subplot(211),plot(w/pi,abs(Y3));

xlabel('\omega/\pi');ylabel('|Y3(e^j^\omega)|');

title('Y3的频率特性');grid;

%画出Y3的频率特性

subplot(212),plot(w/pi,abs(G1));

xlabel('\omega/\pi');ylabel('|G1(e^j^\omega)|');

title('G1的频率特性');grid;

%画出G1的频率特性

%*************************************************************************%

%频域微分

k=0:

N-1;

y4=k.*g;

[Y4,w]=freqz(y4,1);

%在频域进行微分

y0=((-1).^k).*g;

G2=[G(2:

512)'sum(y0)]';

delG=(G2-G)*512/pi;

figure(4);

subplot(211),plot(w/pi,abs(Y4));

xlabel('\omega/\pi');ylabel('|Y4(e^j^\omega)|');

title('Y4的频率特性');grid;

%画出Y4的频率特性

subplot(212),plot(w/pi,abs(delG));

xlabel('\omega/\pi');ylabel('|delG(e^j^\omega)|');

title('delG的频率特性');grid;

%画出delG的频率特性

%*************************************************************************%

%相乘性质

y5=conv(g,h);%时域卷积

[Y5,w]=freqz(y5,1);

figure(5);

subplot(211),plot(w/pi,abs(Y5));

xlabel('\omega/\pi');ylabel('|Y5(e^j^\omega)|');

title('Y5的频率特性');grid;

%画出Y5的频率特性

subplot(212),plot(w/pi,abs(G.*H));%频域乘积

xlabel('\omega/\pi');ylabel('|G.*H(e^j^\omega)|');

title('G.*H的频率特性');grid;

%画出G.*H的频率特性

%*************************************************************************%

%帕斯瓦尔定理

y6=g.*h;

%对于freqz函数,在0到2pi直接取样

[Y6,w]=freqz(y6,1,512,'whole');

[G0,w]=freqz(g,1,512,'whole');

[H0,w]=freqz(h,1,512,'whole');

%Evaluatethesamplevalueatw=pi/2

%andverifywithY6atpi/2

H1=[fliplr(H0(1:

129)')fliplr(H0(130:

512)')]';

val=1/(512)*sum(G0.*H1);

%ComparevalwithY6(129)i.esampleatpi/2

%Canextendthistootherpointssimilarly

%Parsevalstheorem

val1=sum(g.*conj(h));

val2=sum(G0.*conj(H0))/512;

%Comapreval1withval2

3.结果

(a)

(b)

(c)

(d)

(e)

4.结果分析

M3.8

1.题目

UsingmatlabcomputetheN-pointDFTsofthelength-NsequencesofProblem3.12forN=3,5,7,and10.CompareyourresultswiththatobtainedbyevaluatingtheDTFTscomputedinProblem3.12atω=2pik/N,k=0,1,……N-1.

2.程序

%用户定义N的长度

N=input('ThevalueofN=');

k=-N:

N;

y1=ones([1,2*N+1]);

w=0:

2*pi/255:

2*pi;

Y1=freqz(y1,1,w);

%对y1做傅里叶变换

Y1dft=fft(y1);

k=0:

1:

2*N;

plot(w/pi,abs(Y1),k*2/(2*N+1),abs(Y1dft),'o');grid;

xlabel('归一化频率');ylabel('幅度');

(a)clf;

N=input('ThevalueofN=');

k=-N:

N;

y1=ones([1,2*N+1]);

w=0:

2*pi/255:

2*pi;

Y1=freqz(y1,1,w);

Y1dft=fft(y1);

k=0:

1:

2*N;

plot(w/pi,abs(Y1),k*2/(2*N+1),abs(Y1dft),'o');

xlabel('Normalizedfrequency');ylabel('Amplitude');

(b)%用户定义N的长度

N=input('ThevalueofN=');

k=-N:

N;

y1=ones([1,2*N+1]);

y2=y1-abs(k)/N;

w=0:

2*pi/255:

2*pi;

Y2=freqz(y2,1,w);

%对y1做傅里叶变换

Y2dft=fft(y2);

k=0:

1:

2*N;

plot(w/pi,abs(Y2),k*2/(2*N+1),abs(Y2dft),'o');grid;

xlabel('归一化频率');ylabel('幅度');

(c)%用户定义N的长度

N=input('ThevalueofN=');

k=-N:

N;

y3=cos(pi*k/(2*N));

w=0:

2*pi/255:

2*pi;

Y3=freqz(y3,1,w);

%对y1做傅里叶变换

Y3dft=fft(y3);

k=0:

1:

2*N;

plot(w/pi,abs(Y3),k*2/(2*N+1),abs(Y3dft),'o');grid;

xlabel('归一化频率');ylabel('幅度');

3.结果

(a)N=3

N=5

N=7

N=10

(b)N=3

N=5

N=7

N=10

(c)N=3

N=5

N=7

N=10

4.结果分析

M3.19

1.题目

UsingProgram3_10determinethez-transformasaratiooftwopolynomialsinz-1fromeachofthepartial-fractionexpansionslistedbelow:

(a)

(b)

(c)

(d)

2.程序

%Program3_10

%Partical-FractionExpansiontorationalz-Transform

%

r=input('Typeintheresidues=');

p=input('Typeinthepoles=');

k=input('Typeintheconstants=');

[num,den]=residuez(r,p,k);

disp('Numberatorpolynominalcoefficients');disp(num)

disp('Denominatorpolynomialcoefficients');disp(den)

3.结果

4.结果分析

M4.6

1.题目

PlotthemagnitudeandphaseresponsesofthecausalIIRdigitaltransferfunction

Whattypeoffilterdoesthistransferfunctionrepresent?

Determinethedifferenceequationrepresentationoftheabovetransferfunction.

2.程序

b=[0.0534-0.00088644-0.000886440.0534];

a=[1-2.12911.7833863-0.5434631];

figure

(1)

freqz(b,a);

figure

(2)

[H,w]=freqz(b,a);

plot(w/pi,abs(H)),grid;

xlabel('NormalizedFrequency(\times\pirad/sample)'),

ylabel('Magnitude');

3.结果

幅度化成真值之后:

4.结果分

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 农林牧渔 > 林学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1