常用小波函数及 Matlab 常用指令

119
常常常常常常常 常常常常常常常 Matlab Matlab 常常常常 常常常常 常常常常常常 一、 常常常常常常 一、 与与与与与与与与与与 与与与与与与与与与与与与与与与与 ,一 与与与与与与与与与与 与与与与与与与与与与与与与与与与 ,一 与与与与 与与与与与 与与与与与与与与与与与与与与与 与与与与 与与与与与 与与与与与与与与与与与与与与与 与与与与与 与与与与与与与与与与与与 与与与 与与与与与与与与与与 与 一,一一 与与与与与 与与与与与与与与与与与与 与与与 与与与与与与与与与与 与 一,一一 与与 与与与与与与与与与与与与与与与与与与与与与与与与与与与与与与与与 与与 与与与与与与与与与与与与与与与与与与与与与与与与与与与与与与与与 与与与与与与与与 与与与与与与与与与 ,。 与与与与与与与与 与与与与与与与与与 ,。 () x

description

常用小波函数及 Matlab 常用指令. ● 一 、常用小波函数 与标准傅立叶变换相比,小波分析中用到的小波函数没有唯一性,小波函数 具有多样性。由此而带来的问题是使用不同的小波基分析同一个问题会产生不同的结果,没有一个选择最优小波基的统一方法。目前主要是通过用小波分析方法处理信号的结果与理论分析结果的误差莱判定小波基的好坏,并由此选定小波基。. 常用的指导性选择标准有: (1) 的支撑长度。即当时间或频率趋于无穷大时,上述各量从有限值收敛到 0 的速度; (2) 对称型。它在图象处理中对于避免移相非常有用 ; - PowerPoint PPT Presentation

Transcript of 常用小波函数及 Matlab 常用指令

Page 1: 常用小波函数及 Matlab 常用指令

常用小波函数及常用小波函数及 MatlabMatlab 常用指令常用指令 ●● 一 、常用小波函数一 、常用小波函数 与标准傅立叶变换相比,小波分析中用到的小与标准傅立叶变换相比,小波分析中用到的小

波函数没有唯一性,小波函数 具有多样性。由波函数没有唯一性,小波函数 具有多样性。由此而带来的问题是使用不同的小波基分析同一个此而带来的问题是使用不同的小波基分析同一个问题会产生不同的结果,没有一个选择最优小波问题会产生不同的结果,没有一个选择最优小波基的统一方法。目前主要是通过用小波分析方法基的统一方法。目前主要是通过用小波分析方法处理信号的结果与理论分析结果的误差莱判定小处理信号的结果与理论分析结果的误差莱判定小波基的好坏,并由此选定小波基。波基的好坏,并由此选定小波基。

( )x

Page 2: 常用小波函数及 Matlab 常用指令

常用的指导性选择标准有:常用的指导性选择标准有:

(1) (1) 的支撑长度。即当时间或频率趋于无穷的支撑长度。即当时间或频率趋于无穷大时,上述各量从有限值收敛到大时,上述各量从有限值收敛到 00 的速度;的速度;

(2) (2) 对称型。它在图象处理中对于避免移相非常有用对称型。它在图象处理中对于避免移相非常有用 ;;

(3) ((3) ( 若存在若存在 )) 的消失矩阶数。对于压缩非常有用的消失矩阶数。对于压缩非常有用 ;;

(4)(4) 正则性。对信号或图象的重构获得较好的平滑效正则性。对信号或图象的重构获得较好的平滑效果非常有用。果非常有用。

^ ^

、 、 、

Page 3: 常用小波函数及 Matlab 常用指令

11 、、 Haar Haar 小波小波

waveinfo('haar')waveinfo('haar')HAARINFO Information on Haar wavelet.HAARINFO Information on Haar wavelet. Haar WaveletHaar Wavelet General characteristics: Compactly supported General characteristics: Compactly supported wavelet, the oldest and the simplest wavelet.wavelet, the oldest and the simplest wavelet.

scaling function phi = 1 on [0 1] and 0 otherwise.scaling function phi = 1 on [0 1] and 0 otherwise. wavelet function psi = 1 on [0 0.5[, = -1 on [0.5 1] and 0 otherwise.wavelet function psi = 1 on [0 0.5[, = -1 on [0.5 1] and 0 otherwise.

Family HaarFamily Haar Short name haarShort name haar Examples haar is the same as db1Examples haar is the same as db1

其他0

12/11

2/101

x

x

H

Page 4: 常用小波函数及 Matlab 常用指令

Orthogonal yesOrthogonal yes Biorthogonal yesBiorthogonal yes Compact support yesCompact support yes DWT possibleDWT possible CWT possibleCWT possible

Support width 1Support width 1 Filters length 2Filters length 2 Regularity haar is not continuousRegularity haar is not continuous Symmetry yesSymmetry yes Number of vanishing moments for psi 1Number of vanishing moments for psi 1

Page 5: 常用小波函数及 Matlab 常用指令

图图 ::

在命令窗口输入 waveinfo('haar')

Page 6: 常用小波函数及 Matlab 常用指令

DBINFO Information on Daubechies wavelets.DBINFO Information on Daubechies wavelets. Daubechies WaveletsDaubechies Wavelets General characteristics: Compactly supported General characteristics: Compactly supported wavelets with extremal phase and highest num wavelets with extremal phase and highest number of vanishing moments for a given support wiber of vanishing moments for a given support width. Associated scaling filters aredth. Associated scaling filters are minimum-phase filters. minimum-phase filters. Family DaubechiesFamily Daubechies Short name dbShort name db Order N N strictly positive integerOrder N N strictly positive integer Examples db1 or haar, db4, db15Examples db1 or haar, db4, db15

2 、 db 系列小波

Page 7: 常用小波函数及 Matlab 常用指令

Orthogonal yesOrthogonal yes

Biorthogonal yesBiorthogonal yes

Compact support yesCompact support yes

DWT possibleDWT possible

CWT possibleCWT possible

Support width 2N-1Support width 2N-1

Filters length 2NFilters length 2N

Regularity about 0.2 N for large NRegularity about 0.2 N for large N

Symmetry far fromSymmetry far from

Number of vanishing moments for psi NNumber of vanishing moments for psi N

Page 8: 常用小波函数及 Matlab 常用指令

图图 ::

Page 9: 常用小波函数及 Matlab 常用指令

33 、、 Biorthogonal(biorNr.Nd)Biorthogonal(biorNr.Nd) 小波系小波系

主要特点体现在具有线性相位型,主要应用于信主要特点体现在具有线性相位型,主要应用于信

号和图象的重构中。通常表示为号和图象的重构中。通常表示为 biorNr.NdbiorNr.Nd 形式。形式。

Nr=1 Nd=1,3,5; Nr=2 Nd=2,4,6,8Nr=1 Nd=1,3,5; Nr=2 Nd=2,4,6,8

Nr=3 Nd=1,3,5,7,9; Nr=4 Nd=4Nr=3 Nd=1,3,5,7,9; Nr=4 Nd=4

Nr=5 Nd=5; Nr=6 Nd=8Nr=5 Nd=5; Nr=6 Nd=8

Page 10: 常用小波函数及 Matlab 常用指令

General characteristics: Compactly supported General characteristics: Compactly supported biorthogonal spline wavelets for which symmetry and biorthogonal spline wavelets for which symmetry and exact reconstruction are possible with FIR filters (in exact reconstruction are possible with FIR filters (in orthogonal case it is impossible except for Haar).orthogonal case it is impossible except for Haar).

Family BiorthogonalFamily Biorthogonal Short name biorShort name bior Order Nr,Nd Nr = 1 , Nd = 1, 3, 5Order Nr,Nd Nr = 1 , Nd = 1, 3, 5 r for reconstruction Nr = 2 , Nd = 2, 4, 6, 8r for reconstruction Nr = 2 , Nd = 2, 4, 6, 8 d for decomposition Nr = 3 , Nd = 1, 3, 5, 7, 9d for decomposition Nr = 3 , Nd = 1, 3, 5, 7, 9

Nr = 4 , Nd = 4Nr = 4 , Nd = 4 Nr = 5 , Nd = 5Nr = 5 , Nd = 5 Nr = 6 , Nd = 8Nr = 6 , Nd = 8

Page 11: 常用小波函数及 Matlab 常用指令

Examples bior3.1, bior5.5Examples bior3.1, bior5.5 OrthogonalOrthogonal (正交) (正交) nono Biorthogonal(Biorthogonal( 双正交的双正交的 ) yes) yes Compact support yesCompact support yes DWT possibleDWT possible CWT possibleCWT possible Support width 2Nr+1 for rec., 2Support width 2Nr+1 for rec., 2Nd+1 for dec.Nd+1 for dec. Filters length max(2Nr,2Nd)+2 buFilters length max(2Nr,2Nd)+2 but essentiallyt essentially

Page 12: 常用小波函数及 Matlab 常用指令

bior Nr.Nd ld lr bior Nr.Nd ld lr

effective length effective lengtheffective length effective length

of Lo_D of Hi_Dof Lo_D of Hi_D

bior 1.1 2 2 bior 1.1 2 2

bior 1.3 6 2bior 1.3 6 2

bior 1.5 10 2 bior 1.5 10 2

bior 2.2 5 3 bior 2.2 5 3

bior 2.4 9 3 bior 2.4 9 3

bior 2.6 13 3 bior 2.6 13 3

bior 2.8 17 3 bior 2.8 17 3

Page 13: 常用小波函数及 Matlab 常用指令

bior 3.1 4 4 bior 3.1 4 4

bior 3.3 8 4 bior 3.3 8 4

bior 3.5 12 4bior 3.5 12 4

bior 3.7 16 4bior 3.7 16 4

bior 3.9 20 4bior 3.9 20 4

bior 4.4 9 7bior 4.4 9 7

bior 5.5 9 11bior 5.5 9 11

bior 6.8 17 11bior 6.8 17 11

Page 14: 常用小波函数及 Matlab 常用指令

Regularity for psi rec. Nr-1 and Nr-2 at the Regularity for psi rec. Nr-1 and Nr-2 at the knotsknots

Symmetry yes Symmetry yes

Number of vanishing moments for psi dec.Number of vanishing moments for psi dec. Nr Nr

Remark: bior 4.4 , 5.5 and 6.8 are such thRemark: bior 4.4 , 5.5 and 6.8 are such that reconstruction and at reconstruction and

decomposition functions and filters are clodecomposition functions and filters are close in value. se in value.

Page 15: 常用小波函数及 Matlab 常用指令

图图 ::

Page 16: 常用小波函数及 Matlab 常用指令

44 、、 Coiflet(coifN)Coiflet(coifN) 小波系小波系

由由 DaubechiesDaubechies 构造构造 ,N=1,2,3,4,5.,N=1,2,3,4,5. 具有比具有比 dbNdbN 更好更好的的

对称性。从支撑长度看,具有和对称性。从支撑长度看,具有和 db3Ndb3N 及及 sym3Nsym3N 具具有有

相同的支撑长度,从消失矩的数目看,具有和相同的支撑长度,从消失矩的数目看,具有和 db2Ndb2N

和和 symNsymN 相同的消失矩数目。 相同的消失矩数目。

Page 17: 常用小波函数及 Matlab 常用指令

图图 ::

Page 18: 常用小波函数及 Matlab 常用指令

General characteristics: Compactly supported General characteristics: Compactly supported wavelets with highest number of vanishing momwavelets with highest number of vanishing moments for both phi and psi for a given support widtents for both phi and psi for a given support width.h. Family CoifletsFamily Coiflets Short name coifShort name coif Order N N = 1, 2, ..., 5Order N N = 1, 2, ..., 5 Examples coif2, coif4Examples coif2, coif4 Orthogonal yesOrthogonal yes Biorthogonal yesBiorthogonal yes Compact support yesCompact support yes DWT possibleDWT possible CWT possibleCWT possible

Page 19: 常用小波函数及 Matlab 常用指令

Support width 6N-1Support width 6N-1

Filters length 6NFilters length 6N

Regularity Regularity

Symmetry near fromSymmetry near from

Number of vanishing moments for psi Number of vanishing moments for psi 2N 2N

Number of vanishing moments for phi Number of vanishing moments for phi 2N-1 2N-1

Page 20: 常用小波函数及 Matlab 常用指令

55 、、 SymletsA(symN)SymletsA(symN) 小波系小波系SymletsSymlets 函数系由函数系由 DaubechiesDaubechies 提出的近似对称的提出的近似对称的

小波小波函数,是对函数,是对 dbdb 函数的改进,函数的改进, NN == 22 ,, 33 ,…,,…, 88 。。

Page 21: 常用小波函数及 Matlab 常用指令

General characteristics: Compactly supporGeneral characteristics: Compactly supported wavelets with least asymmetry and hited wavelets with least asymmetry and highest number of vanishing moments for a ghest number of vanishing moments for a given support width.given support width. Associated scaling filters are near Associated scaling filters are near

linear-phase filters.linear-phase filters. Family SymletsFamily Symlets Short name symShort name sym Order N N = 2, 3, ...Order N N = 2, 3, ... Examples sym2, sym8Examples sym2, sym8

Page 22: 常用小波函数及 Matlab 常用指令

Orthogonal yesOrthogonal yes

Biorthogonal yesBiorthogonal yes

Compact support yesCompact support yes

DWT possibleDWT possible

CWT possibleCWT possible

Support width 2N-1Support width 2N-1

Filters length 2NFilters length 2N

Regularity Regularity

Symmetry near fromSymmetry near from

Number of vanishing moments for psi NNumber of vanishing moments for psi N

Page 23: 常用小波函数及 Matlab 常用指令

●●66 、、 Molet(morl)Molet(morl) 小波小波小波函数为小波函数为 ::尺度函数不存在,不具有正交性。尺度函数不存在,不具有正交性。Definition: morl(x) = exp(-x^2/2) * cos(5x)Definition: morl(x) = exp(-x^2/2) * cos(5x) Family MorletFamily Morlet Short name morlShort name morl Orthogonal noOrthogonal no Biorthogonal noBiorthogonal no Compact support noCompact support no DWT noDWT no CWT possibleCWT possible

2/ 2 cos5xx Ce x ( )=

Page 24: 常用小波函数及 Matlab 常用指令

Support width infiniteSupport width infinite

Effective support [-4 4]Effective support [-4 4]

Symmetry yesSymmetry yes

Page 25: 常用小波函数及 Matlab 常用指令

77 、、 Mexican Hat (mexh)Mexican Hat (mexh) 小波小波 由由 GaussGauss 函数的二阶导数构成。函数的二阶导数构成。

具有很好的时频局部化能力,尺度函数不存在,不具有正交性。具有很好的时频局部化能力,尺度函数不存在,不具有正交性。Definition: second derivative of the Gaussian probability densitDefinition: second derivative of the Gaussian probability density functiony function mexh(x) = c * exp(-x^2/2) * (1-x^2) wheremexh(x) = c * exp(-x^2/2) * (1-x^2) where

c = 2/(sqrt(3)*pi^{1/4}) c = 2/(sqrt(3)*pi^{1/4})

2/224/1 )1(3

2 xexx )=(

Page 26: 常用小波函数及 Matlab 常用指令

Family Mexican hatFamily Mexican hat Short name mexhShort name mexh Orthogonal noOrthogonal no Biorthogonal noBiorthogonal no Compact support noCompact support no DWT noDWT no CWT possibleCWT possible Support width infiniteSupport width infinite Effective support [-5 5]Effective support [-5 5] Symmetry yesSymmetry yes

Page 27: 常用小波函数及 Matlab 常用指令
Page 28: 常用小波函数及 Matlab 常用指令

88 、、 MeyerMeyer 小波小波 其小波函数和尺度函数其小波函数和尺度函数

在频率域定义,为具在频率域定义,为具有紧支撑的正交小波。有紧支撑的正交小波。

Page 29: 常用小波函数及 Matlab 常用指令

二、小波分析工具箱常用函数介绍二、小波分析工具箱常用函数介绍

11 、、 CwtCwt

功能:一维连续小波变换功能:一维连续小波变换

格式:格式: (1)coefs=cwt(s,scales,’wname’)(1)coefs=cwt(s,scales,’wname’)

(2)coefs=cwt(s,scales,’wname’,’plot’)(2)coefs=cwt(s,scales,’wname’,’plot’)

ss 为待分析信号;为待分析信号;

Page 30: 常用小波函数及 Matlab 常用指令

scalesscales 为尺度向量:可以为离散值,表示为为尺度向量:可以为离散值,表示为[a1,a2,a3 ,…][a1,a2,a3 ,…] ;;也可以为连续值,表示为也可以为连续值,表示为[amin:step:amax][amin:step:amax] ;;还可以是混合情况,需要将离还可以是混合情况,需要将离

散散值写前面,连续值写后面值写前面,连续值写后面[a1,a2,a3 ,amin:step:amax][a1,a2,a3 ,amin:step:amax]

返回值为小波变换系数矩阵,矩阵的行数为尺度个返回值为小波变换系数矩阵,矩阵的行数为尺度个数,每一行的值为该尺度小波变换系数数,每一行的值为该尺度小波变换系数

Page 31: 常用小波函数及 Matlab 常用指令

在命令窗口输入 在命令窗口输入 help cwthelp cwt ,可得指令的功能解释。,可得指令的功能解释。help cwthelp cwt CWT Real or Complex Continuous 1-D wavelet coeffCWT Real or Complex Continuous 1-D wavelet coefficients.icients. COEFS = CWT(S,SCALES,'wname') computes thCOEFS = CWT(S,SCALES,'wname') computes the continuouse continuous wavelet coefficients of the vector S at real, positivewavelet coefficients of the vector S at real, positive SCALES, using wavelet whose name is 'wname'.SCALES, using wavelet whose name is 'wname'. The signal S is real, the wavelet can be real or coThe signal S is real, the wavelet can be real or complex. mplex. COEFS = CWT(S,SCALES,'wname','plot') computCOEFS = CWT(S,SCALES,'wname','plot') computeses and, in addition, plots the continuous waveletand, in addition, plots the continuous wavelet transform coefficients.transform coefficients.

Page 32: 常用小波函数及 Matlab 常用指令

COEFS = CWT(S,SCALES,'wname',PLOTMODE) COEFS = CWT(S,SCALES,'wname',PLOTMODE) computes and,plots the continuous wavelet transfcomputes and,plots the continuous wavelet transform coefficients.orm coefficients. Coefficients are colored using PLOTMODE.Coefficients are colored using PLOTMODE. PLOTMODE = 'lvl' (By scale) or PLOTMODE = 'lvl' (By scale) or PLOTMODE = 'glb' (All scales) orPLOTMODE = 'glb' (All scales) or PLOTMODE = 'abslvl' or 'lvlabs' (Absolute valuPLOTMODE = 'abslvl' or 'lvlabs' (Absolute value and By scale) ore and By scale) or PLOTMODE = 'absglb' or 'glbabs' (Absolute valPLOTMODE = 'absglb' or 'glbabs' (Absolute value and All scales)ue and All scales)………………

Page 33: 常用小波函数及 Matlab 常用指令

%% 一维连续小波变换一维连续小波变换load noissin;load noissin;s=noissin(1:100);s=noissin(1:100);ls=length(s);ls=length(s);w=cwt(s,[12.12,10.24,15.48,1.2,2:2:10],'dbw=cwt(s,[12.12,10.24,15.48,1.2,2:2:10],'db3','plot');3','plot');xlabel('xlabel(' 时间时间 ')')ylabel('ylabel(' 变换尺度变换尺度 ')')

Page 34: 常用小波函数及 Matlab 常用指令
Page 35: 常用小波函数及 Matlab 常用指令

22 、单尺度一维离散小波变换、单尺度一维离散小波变换

格式:(格式:( 11 )) [ca,cd]=dwt(x,’wname’)[ca,cd]=dwt(x,’wname’)

(( 22 )) [ca,cd]=dwt(x,Lo-D,Hi-D)[ca,cd]=dwt(x,Lo-D,Hi-D)

方式(方式( 11 )直接对信号在指定的小波形式下进)直接对信号在指定的小波形式下进行分解,行分解, caca 为低频系数,为低频系数, cdcd 为高频系数;为高频系数;

方式(方式( 22 )先利用小波滤波器指令)先利用小波滤波器指令 wfilterswfilters求求取分解用的低通和高通滤波器取分解用的低通和高通滤波器 ,,然后将信号通过然后将信号通过滤波器进行分解,可以达到同样的效果。滤波器进行分解,可以达到同样的效果。

Page 36: 常用小波函数及 Matlab 常用指令

%%单尺度一维离散小波变换;单尺度一维离散小波变换;load noissin; s=noissin(1:1000);load noissin; s=noissin(1:1000);subplot(411);plot(s)subplot(411);plot(s)[ca1,cd1]=dwt(s,'haar');[ca1,cd1]=dwt(s,'haar');subplot(423);plot(ca1)subplot(423);plot(ca1)ylabel('haar(ca1)');ylabel('haar(ca1)');subplot(424);plot(cd1);subplot(424);plot(cd1);ylabel('haar(cd1)');ylabel('haar(cd1)');[lo_d,hi_d]=wfilters('haar','d');[lo_d,hi_d]=wfilters('haar','d');[ca2,cd2]=dwt(s,lo_d,hi_d);[ca2,cd2]=dwt(s,lo_d,hi_d);subplot(4,2,5);plot(ca2)subplot(4,2,5);plot(ca2)ylabel('haar(ca2)');ylabel('haar(ca2)');subplot(4,2,6);plot(cd2)subplot(4,2,6);plot(cd2)ylabel('haar(cd2)');ylabel('haar(cd2)');

Page 37: 常用小波函数及 Matlab 常用指令
Page 38: 常用小波函数及 Matlab 常用指令

功能:单尺度一维离散小波逆变换功能:单尺度一维离散小波逆变换X = idwt(CA,CD,'wname') ;X = idwt(CA,CD,'wname') ;

X = idwt(CA,CD,Lo_R,Hi_R);X = idwt(CA,CD,Lo_R,Hi_R);

X = idwt(CA,CD,'wname',L) ;X = idwt(CA,CD,'wname',L) ;

X = idwt(CA,CD,Lo_R,Hi_R,L)X = idwt(CA,CD,Lo_R,Hi_R,L)

后两种对信号中间长度为后两种对信号中间长度为 L L 的部分进行重的部分进行重构构

3 3 单尺度一维离散小波逆变换单尺度一维离散小波逆变换 idwtidwt

Page 39: 常用小波函数及 Matlab 常用指令

%%单尺度一维离散小波逆变单尺度一维离散小波逆变换换load noissin;load noissin;s=noissin(1:1000);s=noissin(1:1000);subplot(6,2,1);subplot(6,2,1);plot(s)plot(s)title('title(' 原始信号原始信号 ')')[ca1,cd1]=dwt(s,'db2');[ca1,cd1]=dwt(s,'db2');x1=idwt(ca1,cd1,'db2');x1=idwt(ca1,cd1,'db2');subplot(6,2,5)subplot(6,2,5)plot(x1)plot(x1)title('title(' 小波重构小波重构 ')')errx1max=max(abs(s-x1));errx1max=max(abs(s-x1));errx1=s-x1;errx1=s-x1;

subplot(626)subplot(626)plot(errx1)plot(errx1)title('title(' 小波重构误差小波重构误差 ')')axis([0,1000,-2e-11,2e-11]);axis([0,1000,-2e-11,2e-11]);•[lo_d,hi_d,lo_r,hi_r]=wfilters('db2');•[ca,cd]=dwt(s,lo_d,hi_d);•x2=idwt(ca,cd,lo_r,hi_r);•subplot(6,2,9);•plot(x2);•title('滤波器重构 ')•errx2max=max(abs(s-x2))•errx2=s-x2;•subplot(6,2,10);plot(errx2)•title('滤波器重构误差 ');•axis([0,1000,-2e-11,2e-11]);

Page 40: 常用小波函数及 Matlab 常用指令
Page 41: 常用小波函数及 Matlab 常用指令

44 、小波滤波器、小波滤波器 wfilterswfilters格式格式 ::

(1)[Lo-D,Hi-D,Lo-R,Hi-R]=wfilters(‘wname’)(1)[Lo-D,Hi-D,Lo-R,Hi-R]=wfilters(‘wname’) (2)[f1,f2]=wfilters(‘wname’,’type’)(2)[f1,f2]=wfilters(‘wname’,’type’)

[LO_D,HI_D,LO_R,HI_R] = WFILTERS('wname') [LO_D,HI_D,LO_R,HI_R] = WFILTERS('wname')

computes four filters associated with the orthogocomputes four filters associated with the orthogonal or biorthogonal wavelet named in the stringnal or biorthogonal wavelet named in the string 'wname'. 'wname'.

LO_D, the decomposition low-pass filterLO_D, the decomposition low-pass filter HI_D, the decomposition high-pass filterHI_D, the decomposition high-pass filter LO_R, the reconstruction low-pass filterLO_R, the reconstruction low-pass filter HI_R, the reconstruction high-pass filterHI_R, the reconstruction high-pass filter

Page 42: 常用小波函数及 Matlab 常用指令

[F1,F2] = WFILTERS('wname','type') returns the follo[F1,F2] = WFILTERS('wname','type') returns the follo

wing filters: wing filters:

LO_D and HI_D if 'type' = 'd' (Decomposition filters)LO_D and HI_D if 'type' = 'd' (Decomposition filters)

LO_R and HI_R if 'type' = 'r' (Reconstruction filters)LO_R and HI_R if 'type' = 'r' (Reconstruction filters)

LO_D and LO_R if 'type' = 'l' (Low-pass filters)LO_D and LO_R if 'type' = 'l' (Low-pass filters)

HI_D and HI_R if 'type' = 'h' (High-pass filters)HI_D and HI_R if 'type' = 'h' (High-pass filters)

’’type’=‘d’ type’=‘d’ 分解滤波器 ’分解滤波器 ’ type’=‘R’ type’=‘R’ 重构滤波重构滤波器器

’’type’=‘type’=‘ll’ ’ 低通滤波器 ’低通滤波器 ’ type’=‘type’=‘hh’ ’ 高通滤波高通滤波器器

Page 43: 常用小波函数及 Matlab 常用指令

举例举例[lo_d,hi_d,lo_r,hi_r]=wfilters('haar');[lo_d,hi_d,lo_r,hi_r]=wfilters('haar');figure(1)figure(1) ;; subplot(221)subplot(221) ;;stem(lo_d)stem(lo_d) ;; title('lo-d of haar')title('lo-d of haar') ;;subplot(222)subplot(222)stem(hi_d)stem(hi_d) ;; title('hi-d of haar')title('hi-d of haar')subplot(223)subplot(223) ;; stem(lo_r)stem(lo_r) ;;title('lo-r of haar')title('lo-r of haar')subplot(224)subplot(224)stem(hi_r)stem(hi_r)title('hi-r of haar')title('hi-r of haar')

Page 44: 常用小波函数及 Matlab 常用指令
Page 45: 常用小波函数及 Matlab 常用指令

55 、、 dwtmodedwtmode

功能:离散小波变换拓展模式功能:离散小波变换拓展模式

格式: (格式: ( 11 )) dwtmodedwtmode

(( 22 )) dwtmode(‘mode’)dwtmode(‘mode’)

说明:当对信号或图像的边缘进行处理时,需要说明:当对信号或图像的边缘进行处理时,需要信号的边缘进行拓展。拓展模式有三种。该指令信号的边缘进行拓展。拓展模式有三种。该指令在进行离散小波变换或小波包变换时,进行模式在进行离散小波变换或小波包变换时,进行模式拓展设定。拓展设定。

Page 46: 常用小波函数及 Matlab 常用指令

模式类型 模式类型 类型说明 类型说明

zdp zdp 补零模式,缺省设定 补零模式,缺省设定

sym sym 对称延拓模式,即把对称延拓模式,即把边缘值进行复制 边缘值进行复制

spd spd 平滑模式,对信号边平滑模式,对信号边缘进行某种平滑处理 缘进行某种平滑处理

Page 47: 常用小波函数及 Matlab 常用指令

66 、、 wavedecwavedec 功能:多尺度一维小波分解(一维多分辨分析函功能:多尺度一维小波分解(一维多分辨分析函数)数)格式:(格式:( 11 )) [c,l]=wavedec(x,n,’wname’)[c,l]=wavedec(x,n,’wname’)

(( 22 )) [c,l]=wavedec(x,n,Lo-D,Hi-D)[c,l]=wavedec(x,n,Lo-D,Hi-D) 用小波或分解滤波器对信号用小波或分解滤波器对信号 XX 进行一维多尺度分进行一维多尺度分

解,解, nn 为尺度和正整数。为尺度和正整数。 输出参数输出参数 cc 是由 组成,是由 组成, LL 是由 是由 组成组成。。

1 1[ , , , , ]j j jca cd cd cd

1 1[ , , , , ]j j jca cd cd cd 的长度 的长度 的长度 的长度

Page 48: 常用小波函数及 Matlab 常用指令

图:图:x

ca1 cd1

ca2 cd2

ca3 cd3

ca3 cd3 cd2 cd1C:

L: ca3的长度 cd3的长度 cd2的长度 cd1的长度 x的长度

Page 49: 常用小波函数及 Matlab 常用指令

举例举例%% 多尺度一维离散小波变换;多尺度一维离散小波变换;load sumsin;load sumsin;s=sumsin;s=sumsin;subplot(611)subplot(611)plot(s);plot(s);title('title('原始信号原始信号 ')')[c,l]=wavedec(s,3,'db1');[c,l]=wavedec(s,3,'db1');subplot(613)subplot(613)plot(c);plot(c);title('title(' 信号信号 s3s3 尺度分解尺度分解 ');');

Page 50: 常用小波函数及 Matlab 常用指令

L= 125 125 250 500 1000

Page 51: 常用小波函数及 Matlab 常用指令

77 、、 appcoefappcoef功能:提取一维小波变换低频系数功能:提取一维小波变换低频系数格式:(格式:( 11 )) AA == appcoef(c,l,’wname’,N)appcoef(c,l,’wname’,N)

(( 22 )) AA == appcoef(c,l,’wname’)appcoef(c,l,’wname’)

(( 33 )) AA == appcoef(c,l,Lo-R,Hi-R )appcoef(c,l,Lo-R,Hi-R )

(( 44 )) AA == appcoef(c,l,Lo-R,Hi-R ,N)appcoef(c,l,Lo-R,Hi-R ,N)

说明:该函数是一个一维小波分解函数,用于从 说明:该函数是一个一维小波分解函数,用于从 小波分解结构小波分解结构 [C,L][C,L] 中提取一维信号的低频 中提取一维信号的低频 系数。系数。

Page 52: 常用小波函数及 Matlab 常用指令

格式(格式( 11 )计算尺度)计算尺度 NN 时的低频系数,时的低频系数,

格式(格式( 22 )用于提取最后一个尺度的低频系数,)用于提取最后一个尺度的低频系数,

格式(格式( 33 )和()和( 44 )用滤波器提取低频系数。)用滤波器提取低频系数。

Page 53: 常用小波函数及 Matlab 常用指令

举例举例%% 提取一维小波变换低提取一维小波变换低频系数;频系数;load leleccum;load leleccum;

s=leleccum(1:2000)s=leleccum(1:2000)

subplot(421)subplot(421)

plot(s);plot(s);

title('title('原始信号原始信号 ')')

[c,l]=wavedec(s,3,'db1');[c,l]=wavedec(s,3,'db1');

ca1=appcoef(c,l,'db1',1);ca1=appcoef(c,l,'db1',1);

subplot(445)subplot(445)plot(ca1)plot(ca1)ylabel('ca1');ylabel('ca1');ca2=appcoef(c,l,'dca2=appcoef(c,l,'db1',2);b1',2);subplot(4,8,17)subplot(4,8,17)plot(ca2);plot(ca2);ylabel('ca2');ylabel('ca2');

Page 54: 常用小波函数及 Matlab 常用指令
Page 55: 常用小波函数及 Matlab 常用指令

88 、、 DetcoefDetcoef

功能:提取一维信号小波变换高频系数功能:提取一维信号小波变换高频系数

格式:(格式:( 11 )) d=detcoef(c,l,N) d=detcoef(c,l,N) 提取提取 NN 尺度的高尺度的高

频系数。频系数。

(( 22 ) ) d=detcoef(c,l)d=detcoef(c,l) ,提取最后一尺度的,提取最后一尺度的

高频系数。高频系数。

Page 56: 常用小波函数及 Matlab 常用指令

举例举例%% 提取一维小波变换高提取一维小波变换高频系数;频系数;load leleccum;load leleccum;

s=leleccum(1:2000)s=leleccum(1:2000)

subplot(421)subplot(421)

plot(s);plot(s);

title('title(' 原始信号原始信号 ')')

[c,l]=wavedec(s,3,'db1');[c,l]=wavedec(s,3,'db1');

cd1=detcoef(c,l,1);cd1=detcoef(c,l,1);

subplot(445)subplot(445)plot(cd1)plot(cd1)ylabel('cd1');ylabel('cd1');cd2=detcoef(c,l,2);cd2=detcoef(c,l,2);subplot(4,8,17)subplot(4,8,17)plot(cd2);plot(cd2);ylabel('cd2');ylabel('cd2');

Page 57: 常用小波函数及 Matlab 常用指令
Page 58: 常用小波函数及 Matlab 常用指令

九、九、 WaverecWaverec

功能:多尺度一维小波重构功能:多尺度一维小波重构

格式:(格式:( 11 )) x=waverec(c,l,’wname’)x=waverec(c,l,’wname’)

(( 22 )) x=waverec(c,l,Lo-R,Hi-R)x=waverec(c,l,Lo-R,Hi-R)

(( 33 )) xx = = waverecwaverec (( wavedecwavedec (( x,N,’wavex,N,’wave

name’),’ wavename’)name’),’ wavename’)

说明:该函数用指定的小波函数或重构滤波器对 说明:该函数用指定的小波函数或重构滤波器对

小波分解结构小波分解结构 (C,L)(C,L) 进行多尺度一维小波重构。进行多尺度一维小波重构。

Page 59: 常用小波函数及 Matlab 常用指令

举例举例%% 多尺度一维小波多尺度一维小波重构;重构;load leleccum;load leleccum;s=leleccum(1:3920)s=leleccum(1:3920)subplot(311)subplot(311)plot(s);plot(s);title('title(' 原始信号原始信号 ')')[c,l]=wavedec(s,3,'d[c,l]=wavedec(s,3,'db5');b5');a=waverec(c,l,'db5')a=waverec(c,l,'db5')

subplot(312)subplot(312)plot(a)plot(a)title('title(' 重构信号重构信号 ')')err=s-a;err=s-a;subplot(313)subplot(313)plot(err)plot(err)title('title(' 误差误差 ')')

Page 60: 常用小波函数及 Matlab 常用指令
Page 61: 常用小波函数及 Matlab 常用指令

十、 十、 upwlevupwlev

功能:单尺度一维小波分解的重构功能:单尺度一维小波分解的重构

格式:格式: (1)[nc,nl,ca]=upwlev(c,l,’wname’)(1)[nc,nl,ca]=upwlev(c,l,’wname’)

(2) [nc,nl,ca]=upwlev(c,l,Lo-R, Hi-R)(2) [nc,nl,ca]=upwlev(c,l,Lo-R, Hi-R)

说明:该函数用于对小波分解结构说明:该函数用于对小波分解结构 [C,L][C,L] 进行单尺进行单尺

度重构,返回上一尺度的分解结构并提取最后一度重构,返回上一尺度的分解结构并提取最后一

尺度的低频分量。尺度的低频分量。

Page 62: 常用小波函数及 Matlab 常用指令

%%单尺度一维小波分解的重构;单尺度一维小波分解的重构;load sumsin;load sumsin;s=sumsin;s=sumsin;subplot(611)subplot(611)plot(s);plot(s);title('title('原始信号原始信号 ')')[c,l]=wavedec(s,3,'db1');[c,l]=wavedec(s,3,'db1');subplot(613)subplot(613)plot(c)plot(c)title('title(' 尺度尺度 33 的小波分解结构的小波分解结构 ')')xlabel('xlabel(' 尺度尺度 33 的低频系数和尺度的低频系数和尺度 33 、、 22 、、 11 的高频系数的高频系数 ')')[nc,nl]=upwlev(c,l,'db1');[nc,nl]=upwlev(c,l,'db1');subplot(615);subplot(615);plot(nc);plot(nc);title('title(' 尺度尺度 22 的小波分解结构的小波分解结构 ')')xlabel('xlabel(' 尺度尺度 22 的低频系数和尺度的低频系数和尺度 22 、、 11 的高频系数的高频系数 ')')

等效于 [c,l]=wavedec(s,2,'db1');[c,l]=wavedec(s,2,'db1');plot(c)plot(c)

Page 63: 常用小波函数及 Matlab 常用指令

NL=250 250 500 1000

L= 125 125 250 500 1000

Page 64: 常用小波函数及 Matlab 常用指令

十一、十一、 WrcoefWrcoef功能:对一维小波系数进行单支重构功能:对一维小波系数进行单支重构格式:格式: (1)x=wrcoef(‘type’,c,l,’wname’,N)(1)x=wrcoef(‘type’,c,l,’wname’,N)

(2)x=wrcoef(‘type’,c,l,Lo-R,Hi-R,,N)(2)x=wrcoef(‘type’,c,l,Lo-R,Hi-R,,N)

(3)x=wrcoef(‘type’,c,l,’wname’)(3)x=wrcoef(‘type’,c,l,’wname’)

(4)x=wrcoef(‘type’,c,l,Lo-R,Hi-R)(4)x=wrcoef(‘type’,c,l,Lo-R,Hi-R)

说明:对一维信号的分解结构说明:对一维信号的分解结构 [C,L][C,L] 用指定的小波用指定的小波函数或重构滤波器进行重构。当‘函数或重构滤波器进行重构。当‘ type=a’type=a’ 时,时,对信号的低频部分进行重构,此时对信号的低频部分进行重构,此时 NN 可以为可以为 00 ;;当‘当‘ type=d’type=d’ 时,对信号的高频部分进行重构,时,对信号的高频部分进行重构,此时此时 NN 为正整数。为正整数。

Page 65: 常用小波函数及 Matlab 常用指令

%% 对一维小波系数进行单支重构;对一维小波系数进行单支重构;load sumsin;load sumsin;

s=sumsin;s=sumsin;

subplot(611)subplot(611)

plot(s);plot(s);

title('title(' 原始信号原始信号 ')')

[c,l]=wavedec(s, 5,'sym4');[c,l]=wavedec(s, 5,'sym4');

a5=wrcoef('a',c,l,'sym4',5);a5=wrcoef('a',c,l,'sym4',5);

subplot(613)subplot(613)

plot(a5)plot(a5)

title('title(' 低频部分重构信号低频部分重构信号 ')')

a51=wrcoef('d',c,l,'sym4',5);a51=wrcoef('d',c,l,'sym4',5);

subplot(615)subplot(615)

plot(a51)plot(a51)

title('title(' 高频部分重构信号高频部分重构信号 ')')

Page 66: 常用小波函数及 Matlab 常用指令
Page 67: 常用小波函数及 Matlab 常用指令

十二、十二、 upcoefupcoef

功能:一维系数的直接小波重构功能:一维系数的直接小波重构

格式:(格式:( 11 )) y=upcoef(‘0’,x,’wname’,N)y=upcoef(‘0’,x,’wname’,N)

(( 22 ) ) y=upcoef(‘0’,x,’wname’,N,L)y=upcoef(‘0’,x,’wname’,N,L)

(( 33 ) ) y=upcoef(‘0’,x,Lo-R,Hi-R,N)y=upcoef(‘0’,x,Lo-R,Hi-R,N)

(( 44 ) ) y=upcoef(‘0’,x,Lo-R,Hi-R,N,L)y=upcoef(‘0’,x,Lo-R,Hi-R,N,L)

(( 55 ) ) y=upcoef(‘0’,x,’wname’)y=upcoef(‘0’,x,’wname’)

(( 66 ) ) y=upcoef(‘0’,x,Lo-R,Hi-R)y=upcoef(‘0’,x,Lo-R,Hi-R)

Page 68: 常用小波函数及 Matlab 常用指令

说明:该函数用于一维小波分析,它用来计算向说明:该函数用于一维小波分析,它用来计算向

量量 XX (信号系数)向上(信号系数)向上 NN 步的重构小波系数,步的重构小波系数, NN

为正整数。如果为正整数。如果 00 == aa ,对低频系数进行重构;,对低频系数进行重构;

如果如果 00 == dd ,对高频系数进行重构;对于(,对高频系数进行重构;对于( 22 ))

和(和( 44 ),则是对向量),则是对向量 XX 中间长度为中间长度为 LL 部分进行部分进行

重构。重构。

Page 69: 常用小波函数及 Matlab 常用指令

Load leleccum; s= leleccum(1:2000);Load leleccum; s= leleccum(1:2000);Plot(s)Plot(s)title('title('原始信号原始信号 ');');[c,l]=wavedec(s,3,'db6');[c,l]=wavedec(s,3,'db6');ca1=appcoef(c,l,'db6',1);ca1=appcoef(c,l,'db6',1);sca1=upcoef('a',ca1,'db6',1);sca1=upcoef('a',ca1,'db6',1);subplot(622);plot(sca1);subplot(622);plot(sca1);title('title(' 尺度尺度 11 的低频系数的低频系数 ca1ca1

向上一步重构信号向上一步重构信号 ');');axis([0,2000,200,600]);axis([0,2000,200,600]);sca1l=upcoef('a',ca1,'db6',1,1000);sca1l=upcoef('a',ca1,'db6',1,1000);subplot(625);plot(sca1l);subplot(625);plot(sca1l);title(‘ca1title(‘ca1 向上一步只取向上一步只取 10001000

点重构信号点重构信号 ');');axis([0,2000,200,600]);axis([0,2000,200,600]);

cd1=detcoef(c,l,1);cd1=detcoef(c,l,1);scd1=upcoef('d',cd1,'db6',1);scd1=upcoef('d',cd1,'db6',1);subplot(626);plot(scd1);subplot(626);plot(scd1);title('title(' 尺度尺度 11 的高频系数的高频系数 cd1cd1

向上一步重构信号向上一步重构信号 ');');axis([0,2000,-20,20]);axis([0,2000,-20,20]);[f1,f2]=wfilters('db6','r');[f1,f2]=wfilters('db6','r');ca2=appcoef(c,l,'db6',2);ca2=appcoef(c,l,'db6',2);sca2=upcoef('a',ca2,f1,f2,2);sca2=upcoef('a',ca2,f1,f2,2);subplot(629);plot(sca2);subplot(629);plot(sca2);title('title(' 尺度尺度 22 的低频系数的低频系数 ca2ca2

向上向上 22步重构信号步重构信号 ');');axis([0,2000,200,600]);axis([0,2000,200,600]);

Page 70: 常用小波函数及 Matlab 常用指令
Page 71: 常用小波函数及 Matlab 常用指令

十三、十三、 wpdecwpdec功能:一维小波包的分解功能:一维小波包的分解格式:(格式:( 11 )) T=wpdec(X, N, ’wname’, E, P) T=wpdec(X, N, ’wname’, E, P)

说明:说明: wpdecwpdec 是一个一维小波包分解函数。是一个一维小波包分解函数。它根据小波函数’它根据小波函数’ wname’wname’ (参见(参见 wfilterswfilters )、熵标准)、熵标准 EE和参数和参数 PP对信号对信号 XX 进行进行 NN 层小波包分解,并返回小波包分解结构层小波包分解,并返回小波包分解结构 T, TT, T为树结为树结构。构。 E is a string containing the type of entropy (see WENTROPY):E is a string containing the type of entropy (see WENTROPY):

E = 'shannon', 'threshold', 'norm', 'log energy', 'sure', 'user’.E = 'shannon', 'threshold', 'norm', 'log energy', 'sure', 'user’.

P is an optional parameter:P is an optional parameter:

'shannon' or 'log energy': P is not used'shannon' or 'log energy': P is not used

'threshold' or 'sure' : P is the threshold (0 <= P)'threshold' or 'sure' : P is the threshold (0 <= P)

'norm' : P is a power (1 <= P)'norm' : P is a power (1 <= P)

'user':P is a string containing the name of an user-defined function.'user':P is a string containing the name of an user-defined function.

Page 72: 常用小波函数及 Matlab 常用指令

load noisdopp;load noisdopp;

x=noisdopp;x=noisdopp;

t=wpdec(x,3,'db1','shannon');t=wpdec(x,3,'db1','shannon');

plot(t)plot(t)

Page 73: 常用小波函数及 Matlab 常用指令
Page 74: 常用小波函数及 Matlab 常用指令

Tree Decomposition

(0,0)

(1,0) (1,1)

(2,0) (2,1) (2,2) (2,3)

(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)

200 400 600 800 1000-10

-8

-6

-4

-2

0

2

4

6

8

10data for node: (0) or (0,0).

Page 75: 常用小波函数及 Matlab 常用指令

Tree Decomposition

(0,0)

(1,0) (1,1)

(2,0) (2,1) (2,2) (2,3)

(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)

100 200 300 400 500-15

-10

-5

0

5

10

15data for node: (1) or (1,0).

Page 76: 常用小波函数及 Matlab 常用指令

Tree Decomposition

(0,0)

(1,0) (1,1)

(2,0) (2,1) (2,2) (2,3)

(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)

100 200 300 400 500-4

-3

-2

-1

0

1

2

3data for node: (2) or (1,1).

Page 77: 常用小波函数及 Matlab 常用指令

Tree Decomposition

(0,0)

(1,0) (1,1)

(2,0) (2,1) (2,2) (2,3)

(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)

50 100 150 200 250-15

-10

-5

0

5

10

15

20data for node: (3) or (2,0).

Page 78: 常用小波函数及 Matlab 常用指令

Tree Decomposition

(0,0)

(1,0) (1,1)

(2,0) (2,1) (2,2) (2,3)

(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)

50 100 150 200 250-4

-3

-2

-1

0

1

2

3

4

5data for node: (4) or (2,1).

Page 79: 常用小波函数及 Matlab 常用指令

Tree Decomposition

(0,0)

(1,0) (1,1)

(2,0) (2,1) (2,2) (2,3)

(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)

50 100 150 200 250-4

-3

-2

-1

0

1

2

3data for node: (5) or (2,2).

Page 80: 常用小波函数及 Matlab 常用指令

Tree Decomposition

(0,0)

(1,0) (1,1)

(2,0) (2,1) (2,2) (2,3)

(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)

50 100 150 200 250-3

-2

-1

0

1

2

3

4data for node: (6) or (2,3).

Page 81: 常用小波函数及 Matlab 常用指令

Tree Decomposition

(0,0)

(1,0) (1,1)

(2,0) (2,1) (2,2) (2,3)

(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)

20 40 60 80 100 120-25

-20

-15

-10

-5

0

5

10

15

20data for node: (7) or (3,0).

Page 82: 常用小波函数及 Matlab 常用指令

十四、十四、 wprecwprec功能:一维小波分解的重构功能:一维小波分解的重构格式: 格式: x=wprec(t)x=wprec(t)举例:举例:

load noisdopp; x=noisdopp;load noisdopp; x=noisdopp; figure(1)figure(1) ;; subplot(211)subplot(211) ;; plot(x)plot(x) title('title('原始信号原始信号 ')') t=wpdec(x,3,'db1','shannon');t=wpdec(x,3,'db1','shannon'); x1=wprec(t)x1=wprec(t) subplot(212)subplot(212) plot(x1)plot(x1)title('title(' 重构信号重构信号 ')')

Page 83: 常用小波函数及 Matlab 常用指令
Page 84: 常用小波函数及 Matlab 常用指令

十五、十五、 wpcoefwpcoef

功能:计算小波系数功能:计算小波系数格式格式 : (1)x: (1)x == wpcoefwpcoef (( tt ,, nn )) (2) x(2) x == wpcoefwpcoef (( tt ))说明: 说明: wpcoefwpcoef 是一个一维或二维的小波包是一个一维或二维的小波包分析函数。格式(分析函数。格式( 11 )返回与节点)返回与节点 nn 对应对应的系数。如果的系数。如果 nn 不存在,不存在, xx == [][] ;;xx == wpcoefwpcoef (( tt )等效于)等效于 xx = = wpcoefwpcoef (( tt ,,00 ))

Page 85: 常用小波函数及 Matlab 常用指令

load noisdopp;load noisdopp;

x=noisdopp;x=noisdopp;

figure(1)figure(1)

subplot(311)subplot(311)

plot(x)plot(x)

title('title('原始信号原始信号 ')')

t=wpdec(x,3,'db1','shannon');t=wpdec(x,3,'db1','shannon');

cfs21=wpcoef(t,[2,1]);cfs21=wpcoef(t,[2,1]);

cfs22=wpcoef(t,[2,2]);cfs22=wpcoef(t,[2,2]);

cfs31=wpcoef(t,[3,1]);cfs31=wpcoef(t,[3,1]);

cfs32=wpcoef(t,[3,2]);cfs32=wpcoef(t,[3,2]);

subplot(323);

plot(cfs21);

title(' 小波包 [2,1] 的系数 ');

subplot(324);

plot(cfs22);

title(' 小波包 [2,2] 的系数 ');

subplot(325);

plot(cfs31);

title(' 小波包 [3,1] 的系数 ');

subplot(326);

plot(cfs32);

title(' 小波包 [3,2] 的系数 ');

Page 86: 常用小波函数及 Matlab 常用指令
Page 87: 常用小波函数及 Matlab 常用指令

0 200 400 600 800 1000 1200-10

-5

0

5

10原 始 信 号

0 50 100 150 200 250 300-20

-10

0

10

20[2,0]小 波 包 的 系 数

0 50 100 150 200 250 300-5

0

5

10[2,1]小 波 包 的 系 数

0 20 40 60 80 100 120 140-40

-20

0

20[3,0]小 波 包 的 系 数

0 20 40 60 80 100 120 140-10

-5

0

5

10[3,1]小 波 包 的 系 数

Page 88: 常用小波函数及 Matlab 常用指令

十六、十六、 wprcoefwprcoef

功能:小波包分解系数的重构;功能:小波包分解系数的重构;格式:格式: xx = = wprcoefwprcoef (( tt ,, nn ))说明: 说明: wprcoefwprcoef 是一个一维或二维的小波是一个一维或二维的小波包分析函数,计算节点包分析函数,计算节点 nn 的小波包分解系的小波包分解系数的重构信号。数的重构信号。XX = = wprcoefwprcoef (( tt )= )= wprcoefwprcoef (( tt ,, 00 ))

该函数一次只能对一个节点进行重构,不能该函数一次只能对一个节点进行重构,不能同时对多点进行重构,可以通过多次调用同时对多点进行重构,可以通过多次调用实现。实现。

Page 89: 常用小波函数及 Matlab 常用指令

load noisdopp;load noisdopp;

x=noisdopp(1:1000);x=noisdopp(1:1000);

figure(1)figure(1)

subplot(311)subplot(311)

plot(x)plot(x)

title('title(' 原始信号原始信号 ')')

t=wpdec(x,3,'db1','shannon');t=wpdec(x,3,'db1','shannon');

rcfs=wprcoef(t,[2,0]);rcfs=wprcoef(t,[2,0]);

cfs21=wpcoef(t,[2,0]);cfs21=wpcoef(t,[2,0]);

subplot(312)subplot(312)

plot(cfs21)plot(cfs21)

title(‘title(‘ 小波包节点(小波包节点( 22 ,, 00 )系数)系数 ')')

subplot(313)subplot(313)

plot(rcfs)plot(rcfs)

title(‘title(‘ 重构小波包节点(重构小波包节点( 22 ,, 00 )信号)信号 ')')

Page 90: 常用小波函数及 Matlab 常用指令
Page 91: 常用小波函数及 Matlab 常用指令

十七、十七、 wpfunwpfun功能:小波包函数功能:小波包函数格式: 格式: [WPWS,X] = WPFUN('wname',NUM,PREC) com[WPWS,X] = WPFUN('wname',NUM,PREC) computes the wavelets packets for a wavelet 'wname' (see putes the wavelets packets for a wavelet 'wname' (see WFILTERS), on dyadic intervals of length 1/2^PREC. WFILTERS), on dyadic intervals of length 1/2^PREC. PREC must be a positive integer.PREC must be a positive integer.

Output matrix WPWS contains the W functions of indeOutput matrix WPWS contains the W functions of index from 0 to NUM, stored rowwise as [W0; W1;...; Wnux from 0 to NUM, stored rowwise as [W0; W1;...; Wnum]. Output vector X is the corresponding common X-grim]. Output vector X is the corresponding common X-grid vector. d vector.

[WPWS,X] = WPFUN('wname',NUM) is equivalent to [WPWS,X] = WPFUN('wname',NUM) is equivalent to [WPWS,X] = WPFUN('wname',NUM,7).[WPWS,X] = WPFUN('wname',NUM,7).

Page 92: 常用小波函数及 Matlab 常用指令

十八、十八、 wpspltwpsplt

功能:分解(分割)小波包功能:分解(分割)小波包格式:格式: t= wpsplt(t,n)t= wpsplt(t,n)

returns the modified tree returns the modified tree tt corresponding to the dec corresponding to the decomposition of the node omposition of the node nn..

[t,ca,cd] = wpsplt(t,n)[t,ca,cd] = wpsplt(t,n) with ca = approximation and cd = detail of node n with ca = approximation and cd = detail of node n

for a 1-D decomposition.for a 1-D decomposition.[t, ca,ch,cv,cd] = WPSPLT(T,N)[t, ca,ch,cv,cd] = WPSPLT(T,N) with ca = approximation and ch, cv, cd = (Horiz., Vwith ca = approximation and ch, cv, cd = (Horiz., V

ert. and Diag.) details of node n for a 2-D decomert. and Diag.) details of node n for a 2-D decompositionposition (二维小波变换)(二维小波变换)

Page 93: 常用小波函数及 Matlab 常用指令

举例举例load noisdopp;load noisdopp;x=noisdopp(1:1000);x=noisdopp(1:1000);figure(1)figure(1)subplot(311)subplot(311)plot(x)plot(x)title('title('原始信号原始信号 ')')t=wpdec(x,3,'db1','shannon');t=wpdec(x,3,'db1','shannon');plot(t)plot(t)[wpt,wpd]=wpsplt(t,[3,0]);[wpt,wpd]=wpsplt(t,[3,0]);plot(wpt)plot(wpt)

Page 94: 常用小波函数及 Matlab 常用指令
Page 95: 常用小波函数及 Matlab 常用指令

十九、十九、 wpjoinwpjoin

功能:重新组合小波包功能:重新组合小波包格式及说明:格式及说明: t = wpjoin(t,n) returns the modified tree t correspt = wpjoin(t,n) returns the modified tree t corresponding to a recomposition of the node n.onding to a recomposition of the node n.

t = wpjoin(t) is equivalent to t = wpjoin(t,0).t = wpjoin(t) is equivalent to t = wpjoin(t,0).

[t,x] = wpjoin(t,n) also returns the coefficients[t,x] = wpjoin(t,n) also returns the coefficients

of the node nof the node n 。。[t,x] = wpjoin (t) is equivalent to [t,x] = wpjoin(t,0) [t,x] = wpjoin (t) is equivalent to [t,x] = wpjoin(t,0)

Page 96: 常用小波函数及 Matlab 常用指令

load noisdopp;load noisdopp;x=noisdopp(1:1000);x=noisdopp(1:1000);figure(1)figure(1)subplot(321)subplot(321)plot(x)plot(x)title('title('原始信号原始信号 ')')t=wpdec(x,3,'db1','shannon');t=wpdec(x,3,'db1','shannon');plot(t)plot(t)[wpt,wpc]=wpjoin(t,[1,1]);[wpt,wpc]=wpjoin(t,[1,1]);plot(wpt)plot(wpt)figure(1)figure(1)subplot(322)subplot(322)plot(wpc)plot(wpc)title('title('节点节点 22 的小波包分解系数的小波包分解系数 ')')

Page 97: 常用小波函数及 Matlab 常用指令
Page 98: 常用小波函数及 Matlab 常用指令
Page 99: 常用小波函数及 Matlab 常用指令

二十、二十、 wpcutreewpcutree

功能:剪切小波包分解树功能:剪切小波包分解树格式及说明:格式及说明: t = wpcutree(t,L) cuts the tree t at level L.t = wpcutree(t,L) cuts the tree t at level L.

In addition, [t,rn] = wpcutree(t,L) returns In addition, [t,rn] = wpcutree(t,L) returns

the vector rn which contains the indicesthe vector rn which contains the indices

of the reconstructed nodes.of the reconstructed nodes.

Page 100: 常用小波函数及 Matlab 常用指令

举例举例load noisdopp;load noisdopp;x=noisdopp(1:1000);x=noisdopp(1:1000);figure(1)figure(1)subplot(211)subplot(211)plot(x)plot(x)title('title('原始信号原始信号 ')')t=wpdec(x,3,'db1','shannon');t=wpdec(x,3,'db1','shannon');plot(t)plot(t)[wpt,rn]=wpcutree(t,2);[wpt,rn]=wpcutree(t,2);plot(wpt)plot(wpt)

Page 101: 常用小波函数及 Matlab 常用指令

rn=3rn=3 ,, 44 ,, 55 ,,66

Page 102: 常用小波函数及 Matlab 常用指令

二十一、二十一、 besttreebesttree功能:计算最佳树功能:计算最佳树格式及说明:格式及说明:BESTTREE computes the optimal sub-tree of an initial treeBESTTREE computes the optimal sub-tree of an initial tree with respect to an entropy type criterion. The resulting tree may bwith respect to an entropy type criterion. The resulting tree may be much smaller than the initial one.e much smaller than the initial one.T = BESTTREE(T) computes the modified tree T corresponding to tT = BESTTREE(T) computes the modified tree T corresponding to the best entropy value.he best entropy value.

[T,E] = BESTTREE(T) returns the best tree T and in addition, the b[T,E] = BESTTREE(T) returns the best tree T and in addition, the best entropy value E.est entropy value E. The optimal entropy of the node whose index is j-1 is E(j).The optimal entropy of the node whose index is j-1 is E(j).

[T,E,N] = BESTTREE(T) returns the best tree T, entropy value E a[T,E,N] = BESTTREE(T) returns the best tree T, entropy value E and in addition, the vector N containing the indices of the merged nond in addition, the vector N containing the indices of the merged nodes.des.

Page 103: 常用小波函数及 Matlab 常用指令

举例举例load noisdopp;load noisdopp;x=noisdopp;x=noisdopp;t=wpdec(x,3,'db1','shannon');t=wpdec(x,3,'db1','shannon');x1=wprec(t);x1=wprec(t);[wpt,wpca,wpcd]=wpsplt(t,[3,0]);[wpt,wpca,wpcd]=wpsplt(t,[3,0]);plot(wpt)plot(wpt)[bt,e,n]=besttree(wpt);[bt,e,n]=besttree(wpt);plot(bt)plot(bt)

Page 104: 常用小波函数及 Matlab 常用指令
Page 105: 常用小波函数及 Matlab 常用指令

e'e'

ans =ans =

1.0e+004 *1.0e+004 *

Columns 1 through 8 Columns 1 through 8

-9.8173 -9.7822 -0.0350 -9.7303 -0.0519 -9.5880 -0.1423 -0.031-9.8173 -9.7822 -0.0350 -9.7303 -0.0519 -9.5880 -0.1423 -0.03188

Columns 9 through 11 Columns 9 through 11

-0.0200 -9.3112 -0.2768-0.0200 -9.3112 -0.2768

nn == 22

Page 106: 常用小波函数及 Matlab 常用指令

二十二、二十二、 bestlevtbestlevt

计算完整最佳小波包树计算完整最佳小波包树BESTLEVT computes the optimal complete sub-tree of aBESTLEVT computes the optimal complete sub-tree of an initial tree with respect to an entropy type criterion. Thn initial tree with respect to an entropy type criterion. The resulting complete tree may be of smaller depth than te resulting complete tree may be of smaller depth than the initial one.he initial one.

T = BESTLEVT(T)T = BESTLEVT(T) computes the modified tree T corres computes the modified tree T corresponding to the best level tree decomposition.ponding to the best level tree decomposition. [T,E] = BESTLEVT(T)[T,E] = BESTLEVT(T) returns best tree T and in additio returns best tree T and in addition, the best entropy value E.n, the best entropy value E. The optimal entropy of the node whose index is j-1 is EThe optimal entropy of the node whose index is j-1 is E(j).(j).

Page 107: 常用小波函数及 Matlab 常用指令

load noisdopp;load noisdopp;

x=noisdopp;x=noisdopp;

t=wpdec(x,3,'db1','shannon');t=wpdec(x,3,'db1','shannon');

[wpt,wpca,wpcd]=wpsplt(t,[3,0]);[wpt,wpca,wpcd]=wpsplt(t,[3,0]);

plot(wpt)plot(wpt)

[blt,e]= bestlevt(wpt);[blt,e]= bestlevt(wpt);

plot(blt)plot(blt)

Page 108: 常用小波函数及 Matlab 常用指令
Page 109: 常用小波函数及 Matlab 常用指令

e'e'

ans =ans =

1.0e+004 *1.0e+004 *

Columns 1 through 8 Columns 1 through 8

-5.8615 -6.8204 -0.0350 -7.7901 -0.0497 -0.0205 -0.0138 -5.8615 -6.8204 -0.0350 -7.7901 -0.0497 -0.0205 -0.0138 -8.6844-8.6844

Columns 9 through 15 Columns 9 through 15

-0.1423 -0.0318 -0.0200 -0.0109 -0.0096 -0.0053 -0.0089-0.1423 -0.0318 -0.0200 -0.0109 -0.0096 -0.0053 -0.0089

Page 110: 常用小波函数及 Matlab 常用指令

二十三、二十三、 wp2wtreewp2wtree

从小波包树中提取小波树从小波包树中提取小波树WP2WTREE Extract wavelet tree from wavWP2WTREE Extract wavelet tree from wavelet packet tree.elet packet tree.

t = wp2wtree(t) t = wp2wtree(t)

computes the modified tree T corresponcomputes the modified tree T corresponding to the wavelet decomposition tree.ding to the wavelet decomposition tree.

Page 111: 常用小波函数及 Matlab 常用指令

load noisdopp;load noisdopp;

x=noisdopp;x=noisdopp;

t=wpdec(x,4,'db1','shannon');t=wpdec(x,4,'db1','shannon');

plot(t)plot(t)

wt=wp2wtree(t);wt=wp2wtree(t);

plot(wt)plot(wt)

Page 112: 常用小波函数及 Matlab 常用指令
Page 113: 常用小波函数及 Matlab 常用指令
Page 114: 常用小波函数及 Matlab 常用指令
Page 115: 常用小波函数及 Matlab 常用指令
Page 116: 常用小波函数及 Matlab 常用指令
Page 117: 常用小波函数及 Matlab 常用指令
Page 118: 常用小波函数及 Matlab 常用指令
Page 119: 常用小波函数及 Matlab 常用指令