clc;
clear;
%%
[x,noisyx]=wnoise(3,10,3,2^10); %产生一个长度为2^10点,包含...
%heavy sine信号以及叠加高斯噪声的heavy sine含噪信号,噪声标准差为3
xd1=wden(x,'rigrsure','s','sln',5,'sym8'); %利用sym8小波对信号分解...
%在分解的第5层上,利用软阈值法去噪。
xd2=wden(x,'sqtwolog','h','sln',5,'sym8'); %同样的条件下,利用硬阈值法对信号去噪
fftx=fftshift(fft(x));
fftnoisyx=fftshift(fft(noisyx));
fftxd1=fftshift(fft(xd1));
fftxd2=fftshift(fft(xd2));
t=linspace(0,1,2^10);
fs=2^10;
w=linspace(-fs/2,fs/2,2^10);
figure(1)
subplot(241)
plot(t,x);title('原始信号时域波形');axis tight;
subplot(245)
plot(w,abs(fftx));title('原始信号频域波形');axis tight;
subplot(242)
plot(t,noisyx);title('含噪信号时域波形');axis tight;
subplot(246)
plot(w,abs(fftnoisyx));title('含噪信号频域波形');axis tight;
subplot(243)
plot(t,xd1);title('小波软阈值消噪信号时域波形');axis tight;
subplot(247)
plot(w,abs(fftxd1));title('小波软阈值消噪信号频域波形');axis tight;
subplot(244)
plot(t,xd2);title('小波硬阈值消噪时域波形');axis tight;
subplot(248)
plot(w,abs(fftxd2));title('小波硬阈值消噪频域波形');axis tight;
%%
load noisbloc;
out_xd1=wden(noisbloc,'rigrsure','s','sln',5,'sym8');
out_xd2=wden(noisbloc,'rigrsure','h','sln',5,'sym8');
[b,a]=butter(5,0.3);
out_butter=filter(b,a,noisbloc);
fftnoisbloc=fftshift(fft(noisbloc));
fftout_xd1=fftshift(fft(out_xd1));
fftout_xd2=fftshift(fft(out_xd2));
fftbutter=fftshift(fft(out_butter));
figure(2)
subplot(241)
plot(t,noisbloc);title('含噪信号时域波形');axis tight;
subplot(245)
plot(w,abs(fftnoisbloc));title('含噪信号频域波形');axis tight;
subplot(242)
plot(t,out_xd1);title('小波软阈值消噪信号时域波形');axis tight;
subplot(246)
plot(w,abs(fftout_xd1));title('小波软阈值消噪信号频域波形');axis tight;
subplot(243)
plot(t,out_xd2);title('小波硬阈值消噪时域波形');axis tight;
subplot(247)
plot(w,abs(fftout_xd2));title('小波硬阈值消噪频域波形');axis tight;
subplot(244)
plot(t,out_butter);title('巴特沃斯滤波器消噪时域波形');axis tight;
subplot(248)
plot(w,abs(fftbutter));title('巴特沃斯滤波器消噪频域波形');axis tight;
%%
[s,fs]=audioread('E:\学习\编程\设计\小波变换在语音信号去噪中的应用\cafe_deal.wav');
n=length(s);
noise=0.05*randn(1,n);
y=s+noise';
out=wden(s,'rigrsure','s','sln',5,'sym8');
ffts=fftshift(fft(s,4096))';
ffty=fftshift(fft(y,4096))';
fftout=fftshift(fft(out,4096))';
t01=linspace(0,n/fs,n);
t0=linspace(0,n/fs,4096);
w0=linspace(-fs/2,fs/2,4096);
figure(3)
subplot(231)
plot(t01,s);title('原始信号时域波形');axis tight;
subplot(234)
plot(w0,abs(ffts));title('原始信号频域波形');axis tight;
subplot(232)
plot(t01,y);title('含噪信号时域波形');axis tight;
subplot(235)
plot(w0,abs(ffty));title('含噪信号频域波形');axis tight;
subplot(233)
plot(t01,out');title('消噪信号时域波形');axis tight;
subplot(236)
plot(w0,abs(fftout));title('消噪信号频域波形');axis tight;
xiao_bo.zip_信号加噪_去噪_语音信号_语音信号去噪_语音去噪
版权申诉
30 浏览量
2022-07-15
01:37:34
上传
评论
收藏 1KB ZIP 举报
我虽横行却不霸道
- 粉丝: 72
- 资源: 1万+