Generating Daubechies wavelet function (psi) and wavelet scaling (phi) using Matlab

Matlab provides a function to generate wavelet function values and wavelet scaling values via build-in function called wavefun. (type help wavefun at Matlab command windows for information regarding wavefun function).

However, apart from Matlab build-in function,I’ve found out another way to produce psi and phi function during investigation of Wavelet application to mechanical vibration signal. The script invented make use of a function called daub.m which is taken from Uvi Wave v3 (a free wavelet toolbox for Matlab). Uvi Wave v3 can be downloaded from http://cas.ensmp.fr/~chaplais/UviWave/Uvi_Wave_300.zip. After extracting the zip file, daub.m can be copied from Uvi_Wave_300 folder at /Uvi_Wave_300/wfilter/. Copy the daub.m to a folder which has been included in Matlab search path, or include the entire Uvi_wave_300 folder in Matlab search path.

Here are the codes for producing db(x) wavelet function (psi).

clc; clear all; close all;
%
db_type = 4; % db(x), x = 2,4,6,8, ...
[hh,gg,rh,rg] = daub(db_type); % from Uvi Wave 300
h = rh .* 1.414;
g = rg .* 1.414;
%
psi=1;
psi=conv(psi,g);
n=10;
psi=upsample(psi,2);
%
for i=1:n
psi=conv(psi,h);
if i<n
psi=upsample(psi,2);
end
end
%
x=linspace (0,3,length(psi));
%
plot(x,psi)
judul= ['db',num2str(db_type),' psi (wavelet) function'];
title(judul);

And here are the codes for calculating db(x) scaling function (phi),

clc; clear all; close all;
%
db_type = 4; % db(x), x = 2,4,6,8, ...
[h,g,rh,rg] = daub(db_type); % from Uvi Wave 300
h = rh .* 1.414;
%
phi=1; %initial pulse]
phi=conv(phi,h);
n=10; %number of iteration
phi=upsample(phi,2);
%
for i = 1:n
phi = conv(h,phi) ;
if i<n % last convolved need not go for upsampling
phi = upsample(phi,2);
end
end
%
x = linspace(0,3,length(phi));
%
plot(x,phi,'r-')
judul = ['db',num2str(db_type),' phi (scaling) function'];
title(judul);

Below are the plots produced using wavelet psi and phi script presented above.

db4 psi

 

 

 

 

 

 

 

 

 

 

 

 

 

 

db4 phi

 

 

 

 

 

 

 

 

 

 

 

 

 

 

References:

Advertisements

One thought on “Generating Daubechies wavelet function (psi) and wavelet scaling (phi) using Matlab

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s