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:

The Application of PC Soundcard as A Data Acquisition Device Controlled by MATLAB Data Acquisition Toolbox

The report provides explanation on the design and application of a PC soundcard used as a data acquisition device controlled by Matlab Data Acquisition Toolbox. The idea was based on the needs to apply an economic and reliable data acquisition device to digitize the analogue audible sound wave which can be stored for further analysis. The report covers explanations on the area of Matlab programming in assigning the soundcard as a data acquisition hardware, processing the acquired data in Matlab workspace, plotting the acquired data and technique to store the data acquisition results into hard drive for advanced application and analysis outside Matlab programming environment.

Keywords: Data Acquisition, Matlab, PC Soundcard

Background

In this report a discussion regarding the application of a build-in regular PC soundcard as data acquisition device is explained. The main idea to apply the soundcard as a data acquisition device was based on the fact that getting a special data acquisition board or device used to digitize analogue information of sound wave is expensive. Therefore, the option to use the regular PC soundcard is a reasonable option to capture the magnitude of analogue sound wave by using a microphone connected to soundcard and then convert the captured information into digital form (digitalization). Another reason to use the soundcard was that it becomes an integrated component in every PC used nowadays. Hence, there will be no problem in finding a soundcard attached to a PC that will be used to digitize audible sound wave. Data Acquisition Toolbox from Matlab was used as the software to control the application of a PC soundcard in the digitalization process of audible sound wave received via a microphone. In this design, Matlab was the software used to control and regulate the digitalization process using a soundcard which is applied as the hardware.

The Data Acquisition Toolbox consists of three distinct components: M-file functions, the data acquisition engine, and hardware driver adaptors. These components and relationships are shown in Figure 1. Continue reading