program_02_01.m

来自「小波分析理论与matlab2007配套程序」· M 代码 · 共 69 行

M
69
字号
function program_02_01();
%  多个尺度连续小波变换的实现
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(2,1,1);
plot(vonkoch);
xlabel('时间')
ylabel('幅度')
title('分形信号')
axis([1 510 0 0.02])
 
subplot(2,1,2)
colormap(pink(64));
image(cwtcoef_abs)
set(gca,'YTick',2:3:32)
set(gca,'YTickLabel',32:-3:2)
title('连续小波变换时间尺度图')
xlabel('时间')
ylabel('尺度')


%  某个尺度的连续小波变换的M函数
 
%  delta 小波变换的尺度
%  N     小波函数的长度
%  s     原始信号
%  g     原始信号某个尺度下的小波变换系数
 
function g=Singularity_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);      %  保持信号长度

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?