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.结果分