声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 3647|回复: 10

[小波] 分享最近自己用matlab编写的连续小波变换程序

[复制链接]
发表于 2010-8-19 19:54 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
本帖最后由 xinglong-liu 于 2010-8-19 19:56 编辑

分享最近自己编写的一个连续小波变换程序,希望对大家有用。

close all
clear all;
clc;
dt=1e-2;
t=0:dt:4-dt;
s=sin(12*pi*t);
s(1:end/2) =s(1:end/2)+sin(8*pi*t(1:end/2));
s(end/2+1:end) =s(end/2+1:end)+sin(24*pi*t(end/2+1:end));

N0=length(t)                %should be a even number
figure(2)
subplot(211)
plot(t,s)

fc=2;
fb=2;
T=8;
M0=T/dt;
wc=fc*2*pi;

fmax=20                   %input the highest frequency
fmin=2                      %input the lowest frequency
nscale=64*4;             %input the scale number  
amax=fc/fmin;
amin=fc/fmax;
amax=log2(amax);
amin=log2(amin);
scale=linspace(amin,amax,nscale)';
a=2.^scale;
freq=fc./a;

Mmax=floor(M0*max(a))
Mmax=(2^ceil(log2(2*Mmax+N0))-N0)/2
s=[zeros(1,Mmax) s zeros(1,Mmax)];
N=N0+2*Mmax
S=fft(s);

for m=1:length(a)
    aa=a(m);
    M=floor(M0*aa);
    if ~mod(M,2)
        M=M+1;
    end
    if M<64
        disp('the scale is too small')
    end
    t1=[-(M-1)/2:1:(M-1)/2]*dt;
    t1=t1/aa;
    morlet=(pi*fb)^(-1/2)*exp(i*2*pi*fc*t1).*exp(-t1.^2/fb);
    morlet_R=morlet(1:(M-1)/2);
    morlet_L=morlet((M+1)/2:M);
    morlet=[morlet_L zeros(1,N-M) morlet_R];
    MORLET=fft(morlet);
    Coff=MORLET.*S;
    cwt_morlet(m,:)=ifft(Coff);
end
cwt_coff=cwt_morlet(:,Mmax+1:Mmax+N0);
figure(2)
subplot(212)
set(gcf,'Color','w');
pcolor(t,freq,abs(cwt_coff).^2);
colormap jet;shading interp;

回复
分享到:

使用道具 举报

发表于 2010-8-19 20:57 | 显示全部楼层
太感谢了,最近正研究这个
发表于 2010-8-19 21:35 | 显示全部楼层
回复 xinglong-liu 的帖子
不错

   
发表于 2010-9-8 21:01 | 显示全部楼层
非常不错,很有价值,
发表于 2010-9-9 14:38 | 显示全部楼层
楼主,你的贡献很大啊,谢谢
发表于 2010-9-9 22:20 | 显示全部楼层
刚踏进信号这方面的专业,哎,看着前辈们的成果,很是羡慕
发表于 2010-10-11 15:43 | 显示全部楼层
受益了,谢谢楼主分享
发表于 2010-10-12 11:01 | 显示全部楼层
受益了,谢谢楼主分享
发表于 2010-10-12 20:32 | 显示全部楼层
有些关键步骤的物理意义还是不太懂,楼主可以在加些注释吗,
发表于 2011-12-21 10:36 | 显示全部楼层
非常不错
发表于 2012-3-8 20:33 | 显示全部楼层
已复制保留,呵呵,慢慢学习。
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-6-15 05:46 , Processed in 0.117885 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表