wave let lab
TRANSCRIPT
-
7/28/2019 Wave Let Lab
1/9
Example 1
Generate a 50 Hz 100 V p-p sinusoidal signal (choose 1 kHz sampling frequency and
simulation time from 0.0 to 0.1 sec). Obtain its Continuous Wavelet Transform
(CWT) coefficients by choosing db4 mother wavelet. Plot the CWT coefficients in
3-D space. Observe the plot. Now change the mother wavelet form db4 to morl,harr, db1, db2 etc and obtain the 3-D plot.
Solution:
t=0:0.001:0.1;
y=100*sin(2*pi*50*t);
scale_no=50;c=cwt(y,1:scale_no,'db4');
surf(c) % Surface 3D plot
shading interpcolormap(hsv)
rotate3d on
az=-10;el=16;
view(az,el)
xlabel('Translation');
ylabel('Scale');zlabel('coefficient');
-
7/28/2019 Wave Let Lab
2/9
Example 2
Generate a 50 Hz and 100 Hz 100 V p-p sinusoidal signal (choose 1 kHz sampling
frequency and simulation time from 0.0 to 0.1 sec). Add these two signal. Obtain its
Continuous Wavelet Transform (CWT) coefficients by choosing db4 mother
wavelet. Plot the CWT coefficients in 3-D space. Observe the plot. Now change the
mother wavelet form db4 to morl, harr, db1, db2 etc and obtain the 3-D plot.
Solution:
t=0:0.001:0.1;
y1=100*sin(2*pi*50*t);
t=0:0.001:0.1;
y2=100*sin(2*pi*100*t);
y=y1+y2;
-
7/28/2019 Wave Let Lab
3/9
-
7/28/2019 Wave Let Lab
4/9
Example 3
Generate a 50 Hz and 100 Hz 100 V p-p sinusoidal signal (choose 1 kHz sampling
frequency and simulation time from 0.0 to 0.05 sec for first signal and 0.05 to 0.1 sec
for second signal). Join these two signals. Obtain its Continuous Wavelet Transform
(CWT) coefficients by choosing db4 mother wavelet. Plot the CWT coefficients in3-D space. Observe the plot. Now change the mother wavelet form db4 to morl,
harr, db1, db2 etc and obtain the 3-D plot.
Solution:
t1=0:0.001:0.05;
y1=100*sin(2*pi*50*t1);
t2=0.05:0.001:0.1;
y2=100*sin(2*pi*100*t2);
y=[y1 y2];
-
7/28/2019 Wave Let Lab
5/9
scale_no=50;% Continuous wavelet transform
c=cwt(y,1:scale_no,'db4');
surf(c) % Surface 3D plotshading interp
colormap(hsv)
rotate3d on
az=-10;el=16;
view(az,el)
xlabel('Translation');ylabel('Scale');
zlabel('coefficient');
-
7/28/2019 Wave Let Lab
6/9
Example 4
Generate a 50 Hz noisy sinusoid by adding 2 kHz sinusoid with the 50 Hz sinusoid.
Now calculate the Discrete Wavelet Transform (DWT) of the above signal (choose
db4 mother wavelet and decomposition level upto 9 th level). Recompose the DWT
coefficients in different level and obtain a subplot of those including the originalsignal. Now change the mother wavelet form db4 to morl, harr, db1, db2 etc and
obtain the different subplot.
Solution:
t=0:0.0001:0.1;
y1=100*sin(2*pi*50*t);
t=0:0.0001:0.1;
y2=100*sin(2*pi*2000*t);
y=y1+y2;
[c,l]= wavedec(y,9,'db1');
d9=wrcoef('d',c,l,'db4',9);
d5=wrcoef('d',c,l,'db4',5);
d3=wrcoef('d',c,l,'db4',3);d1=wrcoef('d',c,l,'db4',1);
a9=wrcoef('a',c,l,'db4',9);a5=wrcoef('a',c,l,'db4',5);a3=wrcoef('a',c,l,'db4',3);
a1=wrcoef('a',c,l,'db4',1);
subplot(6,1,1); plot(y);text(1010,5,'Original signal');
subplot(6,1,2);plot(d1);text(1010,5,'Detail Level1');
subplot(6,1,3);plot(a1);text(1010,5,'Approx Level1');subplot(6,1,4);plot(d3);text(1010,5,'Detail Level3');
subplot(6,1,5);plot(a3);text(1010,5,'Approx Level3');
subplot(6,1,6);plot(a5);text(1010,5,'Approx Level5');
-
7/28/2019 Wave Let Lab
7/9
Example 5
Generate a partial discharge signal using the Matlab code shown below. Analyze the
partial discharge signal using DWT
Solution:
%Matlab code to generate PD signalt1=0:0.0001:0.01;
y1=100*sin(2*pi*50*t1);
t2=0.01:0.0001:0.012;
y2=100*sin(2*pi*50*t2)+100*sin(2*pi*1000*t2).*exp(-10*t2);
t3=0.012:0.0001:0.1;
y3=100*sin(2*pi*50*t3);
t=[t1 t2 t3];y=[y1 y2 y3];
%Matlab code for DWT analysis
-
7/28/2019 Wave Let Lab
8/9
ls=length(y);
[c,l]= wavedec(y,9,'db2')
d3=wrcoef('d',c,l,'db2',3);d1=wrcoef('d',c,l,'db2',1);
a1=wrcoef('a',c,l,'db2',1);a3=wrcoef('a',c,l,'db2',3);
subplot(5,1,1); plot(y);text(1010,5,'Original signal')
subplot(5,1,2);plot(d1);text(1010,5,'Detail Level1');subplot(5,1,3);plot(a1);text(1010,5,'Approx Level3');
subplot(5,1,4);plot(d3);text(1010,5,'Detail Level3');
subplot(5,1,5);plot(a3);text(1010,5,'Approx Level3');
Example 6
Take a transformer impulse test signal. Analyze the signal using Wavelet Packet
Transform (WPT) upto level 3.
-
7/28/2019 Wave Let Lab
9/9
Solution:
T = wpdec(s1,5,'db1');plot(T)
ca1=wprcoef(T,[1 0]);
cd1=wprcoef(T,[1 1]);caa2=wprcoef(T,[2 0]);
cda2=wprcoef(T,[2 1]);
cad2=wprcoef(T,[2 2]);cdd2=wprcoef(T,[2 3]);
subplot(4,2,1); plot(s1,'-r');
axis tightsubplot(4,2,3);plot(ca1,'-k');
axis tight
subplot(4,2,4);plot(cd1,'-b');
axis tightsubplot(4,2,5);plot(caa2,'-k');
axis tightsubplot(4,2,6);plot(cda2,'-k');
axis tight
subplot(4,2,7);plot(cad2,'-b');axis tight
subplot(4,2,8);plot(cdd2,'-b');
axis tight