小波分解在信号分析中的应用实例
小波分解在信号分析中的应用实例
1. 含噪的三角波与正弦波的组合
db5小波:

clear all; close all; clc; %******************* 利用小波分解来分析信号 *********************% % 说明:应用db5小波对含噪的三角波和正弦波的组合信号进行7层分解 % 生成正弦信号 N = 1000; t = 1:N; sig1 = sin(0.3*t); % 生成三角波信号 sig2(1:500) = ((1:500)-1)/500; sig2(501:N) = (1000-(501:N))/500; figure(1); subplot(2,1,1); plot(t,sig1,'LineWidth',1); xlabel('样本序号 n'); ylabel('幅值 A'); subplot(2,1,2); plot(t,sig2,'LineWidth',1); xlabel('样本序号 n'); ylabel('幅值 A'); % 叠加信号 x = sig1+sig2+randn(1,N); figure(2); plot(t,x,'LineWidth',1); xlabel('样本序号 n'); ylabel('幅值 A'); title('含噪的三角波与正弦波混合信号波形'); % 一维小波分解 [c,l] = wavedec(x,7,'db5'); % 重构第1-7层逼近系数 a7 = wrcoef('a',c,l,'db5',7); a6 = wrcoef('a',c,l,'db5',6); a5 = wrcoef('a',c,l,'db5',5); a4 = wrcoef('a',c,l,'db5',4); a3 = wrcoef('a',c,l,'db5',3); a2 = wrcoef('a',c,l,'db5',2); a1 = wrcoef('a',c,l,'db5',1); % 显示逼近系数 figure(3); subplot(7,1,1); plot(a7); ylabel('a7'); title('小波分解后各层逼近信号'); subplot(7,1,2); plot(a6); ylabel('a6'); subplot(7,1,3); plot(a5); ylabel('a5'); subplot(7,1,4); plot(a4); ylabel('a4'); subplot(7,1,5); plot(a3); ylabel('a3'); subplot(7,1,6); plot(a2); ylabel('a2'); subplot(7,1,7); plot(a1); ylabel('a1'); xlabel('样本序号 n'); % 重构第1-7层细节系数 d7 = wrcoef('d',c,l,'db5',7); d6 = wrcoef('d',c,l,'db5',6); d5 = wrcoef('d',c,l,'db5',5); d4 = wrcoef('d',c,l,'db5',4); d3 = wrcoef('d',c,l,'db5',3); d2 = wrcoef('d',c,l,'db5',2); d1 = wrcoef('d',c,l,'db5',1); % 显示细节系数 figure(4); subplot(7,1,1); plot(d7); ylabel('d7'); title('小波分解后各层细节信号'); subplot(7,1,2); plot(d6); ylabel('d6'); subplot(7,1,3); plot(d5); ylabel('d5'); subplot(7,1,4); plot(d4); ylabel('d4'); subplot(7,1,5); plot(d3); ylabel('d3'); subplot(7,1,6); plot(d2); ylabel('d2'); subplot(7,1,7); plot(d1); ylabel('d1'); xlabel('样本序号 n');



2. 含噪的多项式信号
db2小波:

db3小波:


clear all; close all; clc; %******************* 利用小波分解来分析信号 *********************% % 说明:应用db2/db3小波对含噪的多项式信号进行4层分解 % 生成含噪多项式信号 N = 800; t = 1:N; sig = t.^2-t+1; x = sig+randn(1,N); figure(1); plot(t,x,'LineWidth',1); xlabel('样本序号 n'); ylabel('幅值 A'); title('含噪的多项式信号波形'); % 一维小波分解 [c,l] = wavedec(x,4,'db2'); % 重构第1-4层逼近系数 a4 = wrcoef('a',c,l,'db2',4); a3 = wrcoef('a',c,l,'db2',3); a2 = wrcoef('a',c,l,'db2',2); a1 = wrcoef('a',c,l,'db2',1); % 显示逼近系数 figure(2); subplot(4,1,1); plot(a4); ylabel('a4'); title('小波分解后各层逼近信号(db2)'); subplot(4,1,2); plot(a3); ylabel('a3'); subplot(4,1,3); plot(a2); ylabel('a2'); subplot(4,1,4); plot(a1); ylabel('a1'); xlabel('样本序号 n'); % 重构第1-4层细节系数 d4 = wrcoef('d',c,l,'db2',4); d3 = wrcoef('d',c,l,'db2',3); d2 = wrcoef('d',c,l,'db2',2); d1 = wrcoef('d',c,l,'db2',1); % 显示细节系数 figure(3); subplot(4,1,1); plot(d4); ylabel('d4'); axis([0 N -100 100]); title('小波分解后各层细节信号(db2)'); subplot(4,1,2); plot(d3); ylabel('d3'); axis([0 N -30 30]); subplot(4,1,3); plot(d2); ylabel('d2'); axis([0 N -5 5]); subplot(4,1,4); plot(d1); ylabel('d1'); axis([0 N -1 1]); xlabel('样本序号 n');
利用db2小波分解后的逼近信号和细节信号如下图。可以看出:这种情况下随着分解层级的增加,其正则性增加,从而抑制了该多项式信号的零阶和一阶部分,而仅对信号的二阶部分以及噪声进行了分解,因此在各层细节信号图中,除了细节信号d1中包含了该含噪信号的不规则性,其余各层信号中的规则性随着层级的增加而增大。


利用db3小波分解后的逼近信号和细节信号如下图。可以看出:由于db3小波的正则性较差,所以它抑制了该信号的多项式部分,而析出了它的噪声部分,因此利用该小波分析可以较好地对该类信号进行抑制。


发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/178681.html原文链接:https://javaforall.net
