x=linspace(-10,10);
y=sinc(x);
plot(x,y);
ylabel('x(t)');
xlabel('t');
title('Sa函数曲线');
1.2.(3)已知LTI离散系统,x(n)=[111],h(n)=[0123],求y(n)
x=[1,1,1,];
h=[0,1,2,3,];
y=conv(x,h);
subplot(2,2,1);stem([0:
length(x)-1],x);
ylabel('x(n)');xlabel('Timeindexn');
subplot(2,2,2);stem([0:
length(h)-1],h);
ylabel('h(n)');xlabel('Timeindexn')
subplot(2,2,3);stem([0:
length(y)-1],y);
ylabel('y(n)=x(n)*h(n)');xlabel('Timeindexn');
第二章
2.1.2.用DFT计算下列信号的频谱:
(1)
N=30;%数据的长度
L=1024;%DFT的点数
f=1/16;fs=600;
T=1/fs;
ws=2*pi*fs;
t=(0:
N-1)*T;
x=5*cos(2*pi*f*t+pi/4);
X=fftshift(fft(x,L));
w=(-ws/2+(0:
L-1)*ws/L)/(2*pi);
plot(w,abs(X));
ylabel('幅度谱')
2.1.(3)
N=30;
L=1024;
f1=0.5;f2=4;fs=600;
T=1/fs;
ws=2*pi*fs;
t=(0:
N-1)*T;
x=2*sin(2*pi*f1*t)+sin(2*pi*f2*t);
X=fftshift(fft(x,L));
w=(-ws/2+(0:
L-1)*ws/L)/(2*pi);
plot(w,abs(X));
ylabel('幅度谱')
第三章
5.采用脉冲响应不变法和双线性变换法设计巴特沃斯数字低通滤波器,满足下列指标:
通带边缘频率:
0.4
,通带衰减:
0.5dB;
阻带边缘频率:
06
,阻带衰减:
50dB
Wp=04*pi;Ws=0.6*pi;Ap=0.5;As=50;
Fs=1;
wp=Wp*Fs;ws=Ws*Fs;
N=buttord(wp,ws,Ap,As,'s');
wc=wp/(10^(0.1*Ap)-1)^(1/2/N);
[numa,dena]=butter(N,wc,'s');
[numd,dend]=impinvar(numa,dena,Fs);
w=linspace(0,pi,512);
h=freqz(numd,dend,w);
norm=max(abs(h));
numd=numd/norm;
plot(w/pi,20*log10(abs(h)/norm))
w=[Wp,Ws];
h=freqz(numd,dend,w);
fprintf('Ap=%.4\n',-20*log10(abs(h
(1))));
fprintf('As=%.4\n',-20*log10(abs(h
(1))));
Wp=04*pi;Ws=0.6*pi;Ap=0.5;As=50;
Fs=0.5;
wp=0.7265;ws=1.3764;
N=buttord(wp,ws,Ap,As,'s');
wc=wp/(10^(0.1*Ap)-1)^(1/2/N);
[numa,dena]=butter(N,wc,'s');
[numd,dend]=bilinear(numa,dena,Fs);
w=linspace(0,pi,512);
h=freqz(numd,dend,w);
norm=max(abs(h));
numd=numd/norm;
plot(w/pi,20*log10(abs(h)/norm))
w=[Wp,Ws];
h=freqz(numd,dend,w);
fprintf('Ap=%.4\n',-20*log10(abs(h
(1))));
fprintf('As=%.4\n',-20*log10(abs(h
(1))));
第四章
3.已知一含有平稳高斯白噪声的序列x[k]=sin(0.8πk)+s[k],试分别用L-D算法和Burg算法实现该序列的功率谱估计,并估计其AR模型参数。
N=512;Nfft=1024;Fs=2*pi;n=0:
N-1;
xn=sin(0.8*pi*n)+randn(size(n));
order=50;
figure
(1)
pburg(xn,order,Nfft,Fs);xlabel('50阶');R=xcorr(xn);
order1=80;
figure
(2)
pburg(xn,order1,Nfft,Fs);xlabel('80阶');L=levinson(R,order)
L=
Columns1through9
1.00000.0742-0.2620-0.5832-0.26570.17150.3907-0.37340.0043
Columns10through18
-0.7425-0.25350.8478-1.0250-0.16731.7374-1.03480.18180.1069
Columns19through27
-2.33890.81891.1640-3.35571.03121.7547-2.38010.75170.7413
Columns28through36
-3.37211.32121.3154-2.71260.36711.4414-0.97850.7407-0.3178
Columns37through45
-1.03060.94740.1621-0.96820.36590.3619-0.1908-0.2529-0.5377
Columns46through51
-0.04140.38430.58930.1865-0.3803-0.5296
N=512;Nfft=1024;Fs=2*pi;n=0:
N-1;
xn=sin(0.8*pi*n)+randn(size(n));
order=50;
figure
(1)
pyulear(xn,order,Nfft,Fs);xlabel('50阶');R=xcorr(xn);
order1=80;
figure
(2)
pyulear(xn,order1,Nfft,Fs);xlabel('80阶');L=levinson(R,order)
L=
Columns1through9
1.0000-0.3463-0.26290.4612-0.4435-0.03160.2078-0.73800.9364
Columns10through18
0.7226-1.11890.7047-0.3691-0.70530.9265-0.2019-0.27090.8969
Columns19through27
-0.94100.69641.0837-0.77290.4398-0.8230-0.08670.07180.2445
Columns28through36
-0.39210.5204-1.25550.55620.5678-0.76900.8311-0.3740-0.3442
Columns37through45
1.0592-0.5897-0.34100.7344-1.43440.25950.7010-0.51600.2881
Columns46through51
-0.0099-0.50540.5843-0.3761-0.67860.7528