t=0:1/44100:(size(s)-1)/44100; %将所加噪声信号的点数调整到与原始信号相同 Au=0.08; %幅度值
d=Au*cos(2*pi*5000*t); %加余弦信号 频率是5000hz n=d';%将噪声进行转置,以便使噪声与信号的行列相同,进行相加 x=s+n;%原始信号和噪声信号叠加
sound(x);
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles) % hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) [s,fs]=audioread ('C:\\Users\\昊东\\Desktop\\zhd.wav');%读取语音信号的数据,赋给变量y 信号 频率
t=0:1/44100:(size(s)-1)/44100; %将所加噪声信号的点数调整到与原始信号相同 Au=0.08; %幅度值
d=Au*cos(2*pi*5000*t); %加余弦信号 频率是5000hz n=d';%将噪声进行转置,以便使噪声与信号的行列相同,进行相加 x=s+n;%原始信号和噪声信号叠加
wp=0.08*pi;ws=0.1*pi; %两个频率的信号
Rp=1;Rs=15;Fs=44100;Ts=1/Fs;%阻带衰减和通带衰减,中间是过渡区,采样频率44100
wp1=2/Ts*tan(wp/2);%将数字指标转换成模拟指标 ws1=2/Ts*tan(ws/2);
[N,Wn]=buttord(wp1,ws1,Rp,Rs,'s');%选择滤波器的最小阶数
15
[Z,P,K]=buttap(N);%创建butterworth模拟滤波器 [Bap,Aap]=zp2tf(Z,P,K); [b,a]=lp2lp(Bap,Aap,Wn);
[bz,az]=bilinear(b,a,Fs);%用双线性变换法实现模拟滤波器到数字滤波器的转换
[H,W]=freqz(bz,az);%绘制频率响应曲线 y=filter(bz,az,x);%调用上边滤波器函数
sound(y);
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles) % hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) wp=0.08*pi;ws=0.1*pi; %两个频率的信号
Rp=1;Rs=15;Fs=44100;Ts=1/Fs;%阻带衰减和通带衰减,中间是过渡区,采样频率44100
wp1=2/Ts*tan(wp/2);%将数字指标转换成模拟指标 ws1=2/Ts*tan(ws/2);
[N,Wn]=buttord(wp1,ws1,Rp,Rs,'s');%选择滤波器的最小阶数 [Z,P,K]=buttap(N);%创建butterworth模拟滤波器 [Bap,Aap]=zp2tf(Z,P,K); [b,a]=lp2lp(Bap,Aap,Wn);
[bz,az]=bilinear(b,a,Fs);%用双线性变换法实现模拟滤波器到数字滤波器的转换
[H,W]=freqz(bz,az);%绘制频率响应曲线 plot(handles.axes4,abs(H))
16