COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Regarding Matlab cwt function

• Follow

```Hi guys,

Well i was looking at the matlab cwt (continuous wavelet transform) function, to understand how are the wavelet coefficients calculated. I understood the steps untill the coefficients are determined.
Here are the steps:
1) Check if the data is numeric, structure or cell? as the data loaded can be of different data types.
2) Check the wavelet if its character, numeric, structure or cell?
This is also understandable.
3) Some more preprocessing of data and wavelet.
4) Coefficients are determined using the equation below for individual scales:
coeff(Index_of_scale,:)= -sqrt(scale) * wkeep1( diff (wconv1 (signal, wavelet), len_of_signal ) );

I can understand that the wavelet needs to be convolved with the signal to represent multiplication in time domain, then why are we differentiating or finding the difference between consecutive data values after the convolution? Which formula or equation was used to determine the coefficients?
```
 0

```"Ravi Rastogi" <raviras@gmail.com> wrote in message <hqhqc2\$1sc\$1@fred.mathworks.com>...
> Hi guys,
>
> Well i was looking at the matlab cwt (continuous wavelet transform) function, to understand how are the wavelet coefficients calculated. I understood the steps untill the coefficients are determined.
> Here are the steps:
> 1) Check if the data is numeric, structure or cell? as the data loaded can be of different data types.
> 2) Check the wavelet if its character, numeric, structure or cell?
> This is also understandable.
> 3) Some more preprocessing of data and wavelet.
> 4) Coefficients are determined using the equation below for individual scales:
> coeff(Index_of_scale,:)= -sqrt(scale) * wkeep1( diff (wconv1 (signal, wavelet), len_of_signal ) );
>
> I can understand that the wavelet needs to be convolved with the signal to represent multiplication in time domain, then why are we differentiating or finding the difference between consecutive data values after the convolution? Which formula or equation was used to determine the coefficients?

Hi Ravi,

The confusion about the use of diff(conv(x,y)) is because what is being fed into the convolution is the integral of the wavelet.

e.g.:
[val_WAV,xWAV] = intwave(WAV,precis);

The derivative of the convolution of two functions f,g is the convolution of the one with the derivative of the other, d/dt (f*g)=(f* d/dt g) and taking the derivative of the integral of the wavelet yields the wavelet. In other words, by using diff() you're just convolving the input function with the wavelet.

Hope that helps,
Wayne
```
 0

```"Wayne King" <wmkingty@gmail.com> wrote in message <hqi4fo\$513\$1@fred.mathworks.com>...
> "Ravi Rastogi" <raviras@gmail.com> wrote in message <hqhqc2\$1sc\$1@fred.mathworks.com>...
> > Hi guys,
> >
> > Well i was looking at the matlab cwt (continuous wavelet transform) function, to understand how are the wavelet coefficients calculated. I understood the steps untill the coefficients are determined.
> > Here are the steps:
> > 1) Check if the data is numeric, structure or cell? as the data loaded can be of different data types.
> > 2) Check the wavelet if its character, numeric, structure or cell?
> > This is also understandable.
> > 3) Some more preprocessing of data and wavelet.
> > 4) Coefficients are determined using the equation below for individual scales:
> > coeff(Index_of_scale,:)= -sqrt(scale) * wkeep1( diff (wconv1 (signal, wavelet), len_of_signal ) );
> >
> > I can understand that the wavelet needs to be convolved with the signal to represent multiplication in time domain, then why are we differentiating or finding the difference between consecutive data values after the convolution? Which formula or equation was used to determine the coefficients?
>
> Hi Ravi,
>
> The confusion about the use of diff(conv(x,y)) is because what is being fed into the convolution is the integral of the wavelet.
>
> e.g.:
> [val_WAV,xWAV] = intwave(WAV,precis);
>
> The derivative of the convolution of two functions f,g is the convolution of the one with the derivative of the other, d/dt (f*g)=(f* d/dt g) and taking the derivative of the integral of the wavelet yields the wavelet. In other words, by using diff() you're just convolving the input function with the wavelet.
>
> Hope that helps,
> Wayne

Hi Wayne,

This defiantly makes sense.
Thanks.

Regards,
Ravi
```
 0

```"Wayne King" <wmkingty@gmail.com> wrote in message <hqi4fo\$513\$1@fred.mathworks.com>...
> "Ravi Rastogi" <raviras@gmail.com> wrote in message <hqhqc2\$1sc\$1@fred.mathworks.com>...
> > Hi guys,
> >
> > Well i was looking at the matlab cwt (continuous wavelet transform) function, to understand how are the wavelet coefficients calculated. I understood the steps untill the coefficients are determined.
> > Here are the steps:
> > 1) Check if the data is numeric, structure or cell? as the data loaded can be of different data types.
> > 2) Check the wavelet if its character, numeric, structure or cell?
> > This is also understandable.
> > 3) Some more preprocessing of data and wavelet.
> > 4) Coefficients are determined using the equation below for individual scales:
> > coeff(Index_of_scale,:)= -sqrt(scale) * wkeep1( diff (wconv1 (signal, wavelet), len_of_signal ) );
> >
> > I can understand that the wavelet needs to be convolved with the signal to represent multiplication in time domain, then why are we differentiating or finding the difference between consecutive data values after the convolution? Which formula or equation was used to determine the coefficients?
>
> Hi Ravi,
>
> The confusion about the use of diff(conv(x,y)) is because what is being fed into the convolution is the integral of the wavelet.
>
> e.g.:
> [val_WAV,xWAV] = intwave(WAV,precis);
>
> The derivative of the convolution of two functions f,g is the convolution of the one with the derivative of the other, d/dt (f*g)=(f* d/dt g) and taking the derivative of the integral of the wavelet yields the wavelet. In other words, by using diff() you're just convolving the input function with the wavelet.
>
> Hope that helps,
> Wayne

Hi Wayne,

This defiantly makes sense.
Thanks.

Regards,
Ravi
```
 0

```"Wayne King" <wmkingty@gmail.com> wrote in message <hqi4fo\$513\$1@fred.mathworks.com>...
> "Ravi Rastogi" <raviras@gmail.com> wrote in message <hqhqc2\$1sc\$1@fred.mathworks.com>...
> > Hi guys,
> >
> > Well i was looking at the matlab cwt (continuous wavelet transform) function, to understand how are the wavelet coefficients calculated. I understood the steps untill the coefficients are determined.
> > Here are the steps:
> > 1) Check if the data is numeric, structure or cell? as the data loaded can be of different data types.
> > 2) Check the wavelet if its character, numeric, structure or cell?
> > This is also understandable.
> > 3) Some more preprocessing of data and wavelet.
> > 4) Coefficients are determined using the equation below for individual scales:
> > coeff(Index_of_scale,:)= -sqrt(scale) * wkeep1( diff (wconv1 (signal, wavelet), len_of_signal ) );
> >
> > I can understand that the wavelet needs to be convolved with the signal to represent multiplication in time domain, then why are we differentiating or finding the difference between consecutive data values after the convolution? Which formula or equation was used to determine the coefficients?
>
> Hi Ravi,
>
> The confusion about the use of diff(conv(x,y)) is because what is being fed into the convolution is the integral of the wavelet.
>
> e.g.:
> [val_WAV,xWAV] = intwave(WAV,precis);
>
> The derivative of the convolution of two functions f,g is the convolution of the one with the derivative of the other, d/dt (f*g)=(f* d/dt g) and taking the derivative of the integral of the wavelet yields the wavelet. In other words, by using diff() you're just convolving the input function with the wavelet.
>
> Hope that helps,
> Wayne

Hi Wayne,

I understood that when we use the function intwave, it loads the values of the wavelet specified and then integrates it to give you val_WAV having points equal to 2^(precis).
Later this wavelet has to be scaled and then translated over the signal to determine the coefficient right? I am not able to get the scaled version of the wavelet, what i get is a part of the wavelet that is being convolved with the SIG.
Here is what i am doing. Where am i going wrong? I want to see the scaled wavelets at individual scales.

%%Load the Wavelet to be used:
WAV='morl';
[val_WAV,xWAV]=intwave(WAV,10); %Precis is value of the octave(p):2^p=length of the wavelet val_WAV
stepWAV = xWAV(2)-xWAV(1);
xMaxWAV = xWAV(end);

%%Plot the Mother Wavelet:
figure;
plot(val_WAV);
title('Mother Wavelet');

%%Enter the Scale at which the wavelet is determined:
a = 15;  %Scale
stepSIG=1;
a_SIG = a/stepSIG; %This helps us in contracting the wavelet in time: largest to smallest as value increases
j = 1+floor((0:a_SIG*xMaxWAV)/(a_SIG*stepWAV));  %This would be a vector
if length(j)==1 , j = [1 1]; end %This was to fix the bug of length=1 data
f = val_WAV(j);  %This would flip the values of the data at positions j from left to right
figure;
plot(f);
title('Plot of the scaled Wavelet');
```
 0

4 Replies
311 Views

Similiar Articles:

7/26/2012 4:22:52 AM