|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
- %%%%%%转载自http://forum.vibunion.com/thread-9141-2-1.html
- clear;
- clc; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %% 1.原始信号 f=50; % 信号频率
- fs=800; % 采样频率
- N=128; % 采样点 % 信号赋值
- n=1:N;
- y=sin(2*pi*f*n/fs); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %% 2.噪声
- noise=0.4*rand(1,128); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %% 3.染噪信号
- y_noise=y+noise; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %% 4.硬消噪采用cycle_spinning技术 % 累加量
- z5=zeros(1,N); % 平移变换频移法
- for i=1:N;
- z=circshift(y_noise.',i-1).'; % 源信号右平移
- [z1,z2]=lwt(z,'db3'); % 小波正变换
- z2=zeros(1,N/2); % 高频分量全部为零(主要噪声,硬消噪)
- z3=ilwt(z1,z2,'db3'); % 小波反变换
- z4=circshift(z3.',-(i-1)).'; % 变换后信号左平移
- z5=z5+z4/N; % 平均
- end;
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %% 5.显示 error=norm(y-z5)/norm(y); % 相对误差 figure(1);
- subplot(2,1,1)
- plot(y,'r');
- legend('源信号');
- subplot(2,1,2);
- plot(y_noise);
- legend('染噪信号');
- figure(2);
- subplot(2,1,1)
- plot(y,'r');
- legend('源信号');
- title(error);
- subplot(2,1,2);
- plot(z5);
- legend('消噪后信号');
|
|