声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1782|回复: 3

[小波] 连续小波变换程序及应用示例

[复制链接]
发表于 2008-1-22 00:00 | 显示全部楼层 |阅读模式

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

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

x
function [WT, FreqBins, Scales] = Wavelet_Morl(Sig,delta,nLevel);
%====================================================================%
%   Morlet Scalogram.                                                                                                                          %
%          Sig : analysed signal                                                                                                               %
%  delta  : control parameter for the length of the mother wavelet                                               %
%  nLevel : number of frequency bins      (default : 1024)                                                               %
%====================================================================%

if (nargin == 0),
error('At least 1 parameter required');
end;

if (nargin < 3),
    nLevel = 512;
elseif (nargin < 2),
    delta = 1;
end;

delta = round(delta);
if(delta < 1);
    delta = 1;
end

Sig = hilbert(real(Sig));
SigLen = length(Sig);
fmax = 0.5;
fmin = 0.001;
FreqBins = logspace(log10(fmin),log10(0.5),nLevel);
Scales = logspace(log10(fmax/fmin),log10(1),nLevel);
WinLen = delta * 6;
WT = zeros(nLevel, SigLen);

wait = waitbar(0,'Under calculation, please wait...');
for m = 1:nLevel,
   
    waitbar(m/nLevel,wait);
    a = Scales(m);
    t = -round(a*WinLen):1:round(a*WinLen);
    Morl = (delta^2 * pi)^(-1/4)*exp(i*pi*t/a).*exp(-t.^2/2/(delta*a)^2);
   
    temp = conv(Sig,Morl) / sqrt(a);
    WT(m,:) = temp(round(a*WinLen)+1:length(temp)-round(a*WinLen));
   
end;
close(wait);

[ 本帖最后由 pengzk 于 2008-1-22 00:18 编辑 ]
回复
分享到:

使用道具 举报

 楼主| 发表于 2008-1-22 00:01 | 显示全部楼层

应用示例

function TestWavelet(),

SampFreq = 100;
t=0:1/SampFreq:10;

sig = [sin(20*pi*t(1:round(end/2))) sin(60*pi*t((round(end/2)+1):end))];

[WT, FreqBins, Scales] = Wavelet_Morl(sig,2,512);
FreqBins = FreqBins * SampFreq;

figure(1)
clf
set(gcf,'Position',[20 100 300 220]);        
set(gcf,'Color','w');                        
pcolor(t,FreqBins,abs(WT).^2);
colormap jet;
shading interp;
axis([min(t) max(t) min(FreqBins) max(FreqBins)]);
colorbar;
ylabel('Frequency / Hz');
xlabel('Time / sec');
title('Wavelet Scalogram')

figure(2)
clf
set(gcf,'Position',[20 100 300 220]);        
set(gcf,'Color','w');                        
pcolor(t,FreqBins,real(WT));
colormap jet;
shading interp;
axis([min(t) max(t) min(FreqBins) max(FreqBins)]);
colorbar;
ylabel('Frequency / Hz');
xlabel('Time / sec');
title('Real Part of Wavelet Transform')

figure(3)
clf
set(gcf,'Position',[20 100 300 220]);        
set(gcf,'Color','w');                        
pcolor(t,FreqBins,real(WT));
colormap jet;
shading interp;
axis([min(t) max(t) min(FreqBins) max(FreqBins)]);
colorbar;
ylabel('Frequency / Hz');
xlabel('Time / sec');
title('Imaginary Part of Wavelet Transform')

figure(4)
clf
PS = zeros(size(WT));
nzero = find(abs(WT)>max(max(abs(WT)))/10);
PS(nzero) = angle(WT(nzero));
set(gcf,'Position',[20 100 300 220]);        
set(gcf,'Color','w');                        
pcolor(t,FreqBins,PS);
colormap jet;
shading interp;
axis([min(t) max(t) min(FreqBins) max(FreqBins)]);
colorbar;
ylabel('Frequency / Hz');
xlabel('Time / sec');
title('Phase Spectrum of Wavelet Transform')

[ 本帖最后由 pengzk 于 2008-1-22 00:05 编辑 ]

评分

1

查看全部评分

发表于 2015-1-29 00:25 | 显示全部楼层
??? Error using ==> Wavelet_Morl
At least 1 parameter required

什么情况?
发表于 2015-2-6 23:20 | 显示全部楼层
jerry0204103 发表于 2015-1-29 00:25
??? Error using ==> Wavelet_Morl
At least 1 parameter required

建议先稍微看下matlab基本操作
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-4-26 16:43 , Processed in 0.091056 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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