2-1是对分形数据进行墨西哥帽子小波变换,实现连续小波变换。程序文件列表,见表1。
表1 程序文件列表
文件 | 作用 |
Singularity_Detection.m | 对已知信号进行墨西哥帽子变换 |
test.m |
对分形数据vonkoch进行变换 |
源程序-Singularity_Detection.m
%某个尺度的连续小波变换的M函数 % delta 小波变换的尺度 % N 小波函数的长度 % s 原始信号 % g 原始信号某个尺度下的小波变换系数 function g= Siguarity_Detection(delta, N, s); % 原始信号长度 n= length(s); % 构造墨西哥帽子小波函数 for index_x= 1: N; x= index_x-(N-1)/2; phi_x(index_x)= ((pi^ (-1/4))*(2/sqrt(3)))*(1-x.*x/(delta^2))*exp(-(x.*x)/(2*delta^2)); end; % 对信号做卷积 phi_x= phi_x/ norm(phi_x); % 能量归一化 g= conv(s,phi_x); % 卷积 g= wkeep(g, n); % 保持信号长度
源程序-test
% 多个尺度连续小波变换的实现 clc;clear % 下载信号 load vonkoch vonkoch= vonkoch(1: 510); % 尺度1-32的连续小波变换 S_Min= 1;S_Max= 32; index= 0; for scale= S_Max:-1:S_Min; index= index+ 1; cwt_coef(index, :)= Singularity_Detection(scale, 32*(scale), vonkoch); end % 小波系数取模 cwtcoef_abs= abs(cwt_coef); % 显示 for index= S_Min: S_Max max_coef= max(cwtcoef_abs(index, :)); % 系数模最大 min_coef= min(cwtcoef_abs(index, :)); % 系数模最小 ext= max_coef-min_coef; % 系数模跨度 cwtcoef_abs(index, :)= 64* (cwtcoef_abs(index, :)- min_coef)/ext; % 系数大小变换 end figure(1) subplot(211); plot(vonkoch); xlabel('时间') ylabel('幅度') title('分形信号') axis([1 510 0 0.02]) subplot(212) colormap(pink(64)); image(cwtcoef_abs); set(gca, 'YTick', 2:3:32); xlabel('时间') ylabel('尺度')
运行结果
图1 运行结果
问题
1-墨西哥帽子小波:常用的连续小波,基本型为(1-t^2)*exp(-t^2/2),由于形状酷似墨西哥玉米片帽子得名,见图2
图2 墨西哥帽子小波
2-wkeep函数:
功能:提取时间序列中的一子列
格式:y= wkeep(x, l, opt)
说明:opt= 'c' 中间提取
opt= 'r' 右端提取
opt= 'l' 左端提取
示例:
>> x = 1:10;
>> yc= wkeep(x,3,'c')
yc =
4 5 6
>> yr= wkeep(x,3,'r')
yr =
8 9 10
>> yl= wkeep(x,3,'l')
yl =
1 2 3
程序中的作用:保持卷积后数据的长度不变
3-系数模大小变化作用:将数据归一化处理,便于colormap显示