Code covered by the BSD License  

Highlights from
continuous wavelet transform and inverse

4.0

4.0 | 2 ratings Rate this file 86 Downloads (last 30 days) File Size: 6.16 KB File ID: #20821
image thumbnail

continuous wavelet transform and inverse

by jon erickson

 

22 Jul 2008 (Updated 25 Feb 2011)

Continuous wavelet transform (CWT) and Inverse CWT for reconstructing original signal.

| Watch this File

File Information
Description

UPDATED FEB 25 2011

This collection of files is an extension of the wavelet software package originally written by Torrence and Compo (http://paos.colorado.edu/research/wavelets/software.html)

The main functions are:

1. contwt.m: (continuous wavelet transform). This is essentially Torrence and Compo's wavelet.m with a few modifications (more inputs and outputs for easier access)

2. invcwt.m: inverse continuous wavelet transform.

Please see the help in each function for details and usage.

Example usage:
%make a test signal
dt = 0.1
t = 0:dt:10;
x = cos(2*t)

%compute the CWT
[wave, period, scale, coi, dj,paramout, k] = contwt(x,dt);

%reconstruct the original signal
Xrec = invcwt(wave, 'MORLET', scale, paramout, k);

%Plot results
figure;
plot(t,x); %original signal
hold on;
plot(t, Xrec, 'r--')
legend('Original signal', 'Reconstructed Signal')
xlabel('Time');
ylabel('Signal (arbitrary units)')

%plot wavelet coeffs
figure;imagesc(abs(wave))
xlabel('Time (integer index)')
ylabel('Scale')

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (15)
02 Nov 2008 Bogdan Hlevca

It would be nice if you had more documentation for the software and attached the data file for the test function.
The link you provided does not work.

20 May 2009 Jon

Bogdan:
The link above is correct if you remove the extra ')' which was accidentally made part of the hyperlink. Sorry about that.

http://paos.colorado.edu/research/wavelets/software.html

worked as of this afternoon when I tested it.

07 Jan 2010 Ajay

The inverse continuous transform does seem to perform a perfect reconstruction. Is there a way to retrieve the original signal back.

07 Jan 2010 Ajay

I meant does not seem to perform perfect reconstruction.

08 Mar 2010 Ravi Rastogi

Hi Jon, I am also having trouble reconstructing the signal back. I get a vector having all values NAN.

07 Jun 2010 jon erickson

Ajay and Ravi,
I have never experienced similar issues.
Please provide more specifics on your problem, and I'll try to respond. E.g., please copy/paste the commands you used. It would also be helpful if you posted an image of your original signal and the (erroneous) output.

30 Nov 2010 Jan Sieber

requested example (what's missing there?) Could be a documentation problem?

%% test invcwt(contwt(y))
dt=1e-3;
t=-pi:dt:pi;
y=sin(t);
% default is MORLET according to documentation:
[wave,per,scale,coi,dj,paramout,k]=contwt(y,dt);
yrec=invcwt(wave,'MORLET',scale,paramout,k);
plot(t,y-yrec);

24 Jan 2011 Wayne Liu

For people who cannot reconstruct the signal, please check your downloaded 'invcwt.m'. In Line 34, if it is calling the function 'wave_bases', change it to 'wave_bases_rec'. Rerun your program and see if it works...

25 Feb 2011 jon erickson

Please note that the reconstructed signal is always centered. That is, the reconstruction process does not/cannot account for any 'dc offset' in the original signal.

01 Apr 2011 Hani Ali

Thank you very much Jon for the great files. Could you please explain how some one could obtain the instantaneous frequency from the transformed wavlet. I found a lot of literature on how to do so for a signal but not its transformed wavlet... I suspect it is rather easy, but i am somewhat lost... Thanks in advance!

02 Apr 2011 jon erickson

If by "instantaneous frequency" you mean the "equivalent Fourier frequency" (i.e. sine wave in infinite time domain at oscillating at a single frequency), then here's the answer. The CWT "pseudofrequency" depends on the mother wavelet you use for the transform. Each mother wavelet has a corresponding "center frequency", and the relation is given as:

f = centerfrq(mother)/(a*delta).
a = scale
delta = sampling period.

I strongly encourage you to read up on wavelet theory, in order to become a competent user of this code.

03 Aug 2011 Alexandre

Could you please explain how this differ from the Wavelet Toolbox (cwt.m function) ? Thanks.

16 Aug 2011 zahra Khawaja

When I decompose the signal with the CWT, how can i reconstruct the details coefficients and the approximations coefficients, like in the discrete wavelet when we use the matlab function (wrcoef)?

12 Oct 2011 jon erickson

Alexandre: MATLAB did not used to have the inverse cwt function in their wavelet toolbox as of 2008. Hence, at that time, it was filling a gap--that matlab hadn't yet implemented. I have not used the newer version of matlab wavelet toolbox, but my guess is that it is the same concept, but less full-fledged.

Zahra: CWT does not share the same notion of details and approximations--that is DWT only.

13 Nov 2011 ernesto

hey friends Im working with myoelectric signal and i need to use the wavelet transform for processing the signal and i need some like a tutorial for get some knowledge

Please login to add a comment or rating.
Updates
25 Feb 2011

-Added example usage.
-Added screen shot.
-Reloaded updated files, which should resolve the issues using wave_bases.m vs wave_bases_rec.m

Tag Activity for this File
Tag Applied By Date/Time
time frequency jon erickson 22 Oct 2008 10:11:18
wavelets jon erickson 22 Oct 2008 10:11:18
cwt jon erickson 22 Oct 2008 10:11:18
wavelet jon erickson 22 Oct 2008 10:11:18
timefrequency jon erickson 22 Oct 2008 10:11:18
signal processing jon erickson 22 Oct 2008 10:11:18
inverse jon erickson 22 Oct 2008 10:11:18
cwt Md. Ali 18 Jan 2012 22:13:25

Contact us at files@mathworks.com