2-1是對分形數據進行墨西哥帽子小波變換,實現連續小波變換。程序文件列表,見表1。python
表1 程序文件列表函數
文件 | 做用 |
Singularity_Detection.m | 對已知信號進行墨西哥帽子變換 |
test.m |
對分形數據vonkoch進行變換 |
源程序-Singularity_Detection.mspa
%某個尺度的連續小波變換的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); % 保持信號長度
源程序-testcode
% 多個尺度連續小波變換的實現 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('尺度')
運行結果orm
圖1 運行結果it
問題io
1-墨西哥帽子小波:經常使用的連續小波,基本型爲(1-t^2)*exp(-t^2/2),因爲形狀酷似墨西哥玉米片帽子得名,見圖2table
圖2 墨西哥帽子小波function
2-wkeep函數:class
功能:提取時間序列中的一子列
格式: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顯示