连续小波变换程序及应用示例
function = 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 编辑 ]
应用示例
function TestWavelet(),SampFreq = 100;
t=0:1/SampFreq:10;
sig = ;
= Wavelet_Morl(sig,2,512);
FreqBins = FreqBins * SampFreq;
figure(1)
clf
set(gcf,'Position',);
set(gcf,'Color','w');
pcolor(t,FreqBins,abs(WT).^2);
colormap jet;
shading interp;
axis();
colorbar;
ylabel('Frequency / Hz');
xlabel('Time / sec');
title('Wavelet Scalogram')
figure(2)
clf
set(gcf,'Position',);
set(gcf,'Color','w');
pcolor(t,FreqBins,real(WT));
colormap jet;
shading interp;
axis();
colorbar;
ylabel('Frequency / Hz');
xlabel('Time / sec');
title('Real Part of Wavelet Transform')
figure(3)
clf
set(gcf,'Position',);
set(gcf,'Color','w');
pcolor(t,FreqBins,real(WT));
colormap jet;
shading interp;
axis();
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',);
set(gcf,'Color','w');
pcolor(t,FreqBins,PS);
colormap jet;
shading interp;
axis();
colorbar;
ylabel('Frequency / Hz');
xlabel('Time / sec');
title('Phase Spectrum of Wavelet Transform')
[ 本帖最后由 pengzk 于 2008-1-22 00:05 编辑 ] ??? Error using ==> Wavelet_Morl
At least 1 parameter required
什么情况? jerry0204103 发表于 2015-1-29 00:25
??? Error using ==> Wavelet_Morl
At least 1 parameter required
建议先稍微看下matlab基本操作
页:
[1]