1.代码
clear clc %计算尺度函数和小波函数 wname='sym4'; [phi,psi,xval]=wavefun(wname,3);%返回尺度函数和小波函数 figure(1) subplot(1,2,1) plot(xval,phi) title('sym4尺度函数'); subplot(1,2,2) plot(xval,psi) title('sym4小波函数') %计算与wname指定的小波名称相关的4个滤波器 wname='db5'; [LoD,HiD,LoR,HiR] = wfilters(wname); figure(2) subplot(2,2,1) stem(LoD) title('分解低通滤波器') subplot(2,2,2) stem(HiD) title('分解高通滤波器') subplot(2,2,3) stem(LoR) title('重构低通滤波器') subplot(2,2,4) stem(HiR) title('重构高通滤波器') %一维离散小波变换 load sumsin figure(3) subplot(5,1,1) plot(sumsin) title('Signal') %使用小波haar返回一维信号sumsin在第3层的小波分解 [c,l]=wavedec(sumsin,3,'haar'); approx=appcoef(c,l,'haar'); [cd1,cd2,cd3]=detcoef(c,l,[1 2 3]); subplot(5,1,2) plot(approx) title('Level 3 Approximation Coefficients') subplot(5,1,3) plot(cd3) title('Level 3 Detail Coefficients') subplot(5,1,4) plot(cd2) title('Level 2 Detail Coefficients') subplot(5,1,5) plot(cd1) title('Level 1 Detail Coefficients')
2.运行结果