考试必备模板2
load DATA9.TXT;
data=DATA9;
fs=10000;
dt=1/fs;
N=length(data);
t=[0:N-1]*dt;
y1=data(:,2);
y2=data(:,3);
y3=data(:,4);
y4=data(:,5);
y5=data(:,6);
y6=data(:,7);
y7=data(:,8);
y8=data(:,9);
figure(1);
plot(t,y1,‘r’);
grid on;
hold on;
plot(t,y6,‘b’);
grid on;
legend(‘信号y1’,‘信号y6’);
xlabel(‘Time/s’);
title(‘原始声信号y1和y6’)
hold on;
Y1=fft(y1,1024);Y6=fft(y6,1024);
Pyy1=Y1.*conj(Y1)/1024; Pyy6=Y6.conj(Y6)/1024;
f=fs/1024(0:127);
figure(2);
subplot(2,1,1)
plot(f,Pyy1(1:128));
xlim([0 500]);
xlabel(‘t/s’);
title(‘y1频谱’);
subplot(2,1,2)
plot(f,Pyy1(1:128));
xlim([0 500]);
xlabel(‘t/s’);
title(‘y6频谱’);
[b1,a1]=ellip(4,0.2,40,[50 200]2/fs);
[b2,a2]=ellip(4,0.2,40,202/fs);
sf1=filter(b1,a1,y1);
sf2=filter(b2,a2,y6);
figure(3);
plot(t,sf1,‘r’,t,sf2,‘b’);
legend(‘信号y1’,‘信号y6’);
xlabel(‘t/s’);
title(‘滤波信号y1、y6’);
sound(sf1,fs);