close all;
i=1;
[x,fs,bits]=wavread('11.wav'); %x:语音数据;fs:采样频率;bits:采样点数
N=length(x);
n=0:N-1;
figure(i);
subplot(2,1,1);
plot(n,x); %画出原始语音信号的波形
xlabel('n');
ylabel('x(n)');
title('原始语音信号');
subplot(2,1,2);
[H,f]=freqz(x,1,512,fs);
plot(f,20*log10(abs(H))); %画出原始语音信号的频谱
xlabel('n');
ylabel('x(n)');
title('原始语音信号的频谱');
f=fft(x,N); %对语音号进行快速傅里叶变换,得出频谱
i=i+1;
figure
plot(abs(n),abs(f));
xlabel('k');
ylabel('|y(k)|');
title('FFT后的波形');
rp=0.1;rs=60;
wp1=2*400/fs;ws1=2*700/fs;
[N1,wpo1]=ellipord(wp1,ws1,rp,rs);
[B1,A1]=ellip(N1,rp,rs,wpo1);
[H1,w1]=freqz(B1,A1,1000);
figure;
subplot(3,1,1);
plot(w1/pi,20*log10(abs(H1)));grid;
xlabel('w');ylabel('H1幅度/dB');
subplot(3,1,2);
plot(w1/pi,angle(H1));grid
xlabel('w');ylabel('H1相位/rad');
y1=filter(B1,A1,x);
subplot(3,1,3);
plot(n,y1);
title('低通滤波后得到的y1(t)的波形');
xlabel('t');ylabel('y1(t)');
rp=0.1;rs=60;
wp2=[2*800/fs,2*1000/fs];
ws2=[2*700/fs,2*1100/fs];
[N2,wpo2]=ellipord(wp2,ws2,rp,rs);
[B2,A2]=ellip(N2,rp,rs,wpo2);
[H2,w2]=freqz(B2,A2,1000);
figure;
subplot(3,1,1);
plot(w2/pi,20*log10(abs(H2)));grid;
xlabel('w');ylabel('H2幅度/dB');
subplot(3,1,2);
plot(w2/pi,angle(H2));grid
xlabel('w');ylabel('H2相位/rad');
y2=filter(B2,A2,x);
subplot(3,1,3);
plot(n,y2);
title('带通滤波后得到的y2(t)的波形');
xlabel('t');ylabel('y2(t)');
rp=0.1;rs=60;
wp3=[2*1300/fs,2*1500/fs];
ws3=[2*1100/fs,2*1700/fs];
[N3,wpo3]=ellipord(wp3,ws3,rp,rs);
[B3,A3]=ellip(N3,rp,rs,wpo3);
[H3,w3]=freqz(B3,A3,1000);
figure;
subplot(3,1,1);
plot(w3/pi,20*log10(abs(H3)));grid;
xlabel('w');ylabel('H2幅度/dB');
subplot(3,1,2);
plot(w3/pi,angle(H3));grid
xlabel('w');ylabel('H3相位/rad');
y3=filter(B3,A3,x);
subplot(3,1,3);
plot(n,y3);
title('带通滤波后得到的y3(t)的波形');
xlabel('t');ylabel('y3(t)');
rp=0.1;rs=60;
wp4=[2*2000/fs,2*2200/fs];
ws4=[2*1700/fs,2*2500/fs];
[N4,wpo4]=ellipord(wp4,ws4,rp,rs);
[B4,A4]=ellip(N4,rp,rs,wpo4);
[H4,w4]=freqz(B4,A4,1000);
figure;
subplot(3,1,1);
plot(w4/pi,20*log10(abs(H4)));grid;
xlabel('w');ylabel('H4幅度/dB');
subplot(3,1,2);
plot(w4/pi,angle(H4));grid
xlabel('w');ylabel('H4相位/rad');
y4=filter(B4,A4,x);
subplot(3,1,3);
plot(n,y4);
title('带通滤波后得到的y4(t)的波形');
xlabel('t');ylabel('y4(t)');
rp=0.1;rs=60;
wp5=[2*3000/fs,2*3500/fs];
ws5=[2*2500/fs,2*4000/fs];
[N5,wpo5]=ellipord(wp5,ws5,rp,rs);
[B5,A5]=ellip(N5,rp,rs,wpo5);
[H5,w5]=freqz(B5,A5,1000);
figure;
subplot(3,1,1);
plot(w5/pi,20*log10(abs(H5)));grid;
xlabel('w');ylabel('H5幅度/dB');
subplot(3,1,2);
plot(w5/pi,angle(H5));grid
xlabel('w');ylabel('H5相位/rad');
y5=filter(B5,A5,x);
subplot(3,1,3);
plot(n,y5);
title('带通滤波后得到的y5(t)的波形');
xlabel('t');ylabel('y2(t)');
rp=0.1;rs=60;
wp6=[2*4600/fs,2*5000/fs];
ws6=[2*4000/fs,2*5800/fs];
[N6,wpo6]=ellipord(wp6,ws6,rp,rs);
[B6,A6]=ellip(N6,rp,rs,wpo6);
[H6,w6]=freqz(B6,A6,1000);
figure;
subplot(3,1,1);
plot(w6/pi,20*log10(abs(H6)));grid;
xlabel('w');ylabel('H6幅度/dB');
subplot(3,1,2);
plot(w6/pi,angle(H6));grid
xlabel('w');ylabel('H6相位/rad');
y6=filter(B6,A6,x);
subplot(3,1,3);
plot(n,y6);
title('带通滤波后得到的y6(t)的波形');
xlabel('t');ylabel('y6(t)');
rp=0.1;rs=60;
wp7=[2*6400/fs,2*6800/fs];
ws7=[2*5800/fs,2*7500/fs];
[N7,wpo7]=ellipord(wp7,ws7,rp,rs);
[B7,A7]=ellip(N7,rp,rs,wpo7);
[H7,w7]=freqz(B7,A7,1000);
figure;
subplot(3,1,1);
plot(w7/pi,20*log10(abs(H7)));grid;
xlabel('w');ylabel('H7幅度/dB');
subplot(3,1,2);
plot(w7/pi,angle(H7));grid
xlabel('w');ylabel('H7相位/rad');
y7=filter(B7,A7,x);
subplot(3,1,3);
plot(n,y7);
title('带通滤波后得到的y7(t)的波形');
xlabel('t');ylabel('y7(t)');
rp=0.1;rs=60;
wp8=2*10000/fs;ws8=2*7500/fs;
[N8,wpo8]=ellipord(wp8,ws8,rp,rs);
[B8,A8]=ellip(N8,rp,rs,wpo8,'high');
[H8,w8]=freqz(B8,A8,1000);
figure;
subplot(3,1,1);
plot(w8/pi,20*log10(abs(H8)));grid;
xlabel('w');ylabel('H8幅度/dB');
subplot(3,1,2);
plot(w8/pi,angle(H8));grid on
xlabel('w');ylabel('H8相位/rad');
y8=filter(B8,A8,x);
subplot(3,1,3);
plot(n,y8);
title('高通滤波后得到的y8(t)的波形');
xlabel('t');ylabel('y8(t)');
z2=abs(y2);
rp=0.1;rs=60;
wp1=2*400/fs;ws1=2*700/fs;
[N1,wpo1]=ellipord(wp1,ws1,rp,rs);
[B1,A1]=ellip(N1,rp,rs,wpo1);
[H1,w1]=freqz(B1,A1,1000);
figure;
y21=filter(B1,A1,z2);
plot(n,y21);
title('y21(t)的包络');
xlabel('t');ylabel('y21(t)');
z3=abs(y3);
rp=0.1;rs=60;
wp1=2*400/fs;ws1=2*700/fs;
[N1,wpo1]=ellipord(wp1,ws1,rp,rs);
[B1,A1]=ellip(N1,rp,rs,wpo1);
[H1,w1]=freqz(B1,A1,1000);
figure;
y31=filter(B1,A1,z3);
plot(n,y31);
title('y31(t)的包络');
xlabel('t');ylabel('y31(t)');
z4=abs(y4);
rp=0.1;rs=60;
wp1=2*400/fs;ws1=2*700/fs;
[N1,wpo1]=ellipord(wp1,ws1,rp,rs);
[B1,A1]=ellip(N1,rp,rs,wpo1);
[H1,w1]=freqz(B1,A1,1000);
figure;
y41=filter(B1,A1,z4);
plot(n,y41);
title('y41(t)的包络');
xlabel('t');ylabel('y41(t)');
z5=abs(y5);
rp=0.1;rs=60;
wp1=2*400/fs;ws1=2*700/fs;
[N1,wpo1]=ellipord(wp1,ws1,rp,rs);
[B1,A1]=ellip(N1,rp,rs,wpo1);
[H1,w1]=freqz(B1,A1,1000);
figure;
y51=filter(B1,A1,z5);
plot(n,y51);
title('y51(t)的包络');
xlabel('t');ylabel('y51(t)');
z6=abs(y6);
rp=0.1;rs=60;
wp1=2*400/fs;ws1=2*700/fs;
[N1,wpo1]=ellipord(wp1,ws1,rp,rs);
[B1,A1]=ellip(N1,rp,rs,wpo1);
[H1,w1]=freqz(B1,A1,1000);
figure;
y61=filter(B1,A1,z6);
plot(n,y61);
title('y61(t)的包络');
xlabel('t');ylabel('y61(t)');
z7=abs(y7);
rp=0.1;rs=60;
wp1=2*400/fs;ws1=2*700/fs;
[N1,wpo1]=ellipord(wp1,ws1,rp,rs);
[B1,A1]=ellip(N1,rp,rs,wpo1);
[H1,w1]=freqz(B1,A1,1000);
figure;
y71=filter(B1,A1,z7);
plot(n,y71);
title('y71(t)的包络');
xlabel('t');ylabel('y71(t)');
z8=abs(y8);
rp=0.1;rs=60;
wp1=2*400/fs;ws1=2*700/fs;
[N1,wpo1]=ellipord(wp1,ws1,rp,rs);
[B1,A1]=ellip(N1,rp,rs,wpo1);
[H1,w1]=freqz(B1,A1,1000);
figure;
y81=filter(B1,A1,z8);
plot(n,y81);
title('y81(t)的包络');
xlabel('t');ylabel('y81(t)');