how to make frequency vs. time figure in wavelet decomposition?

Hi Matlab guru,
I was able to acquire my signal's detail coefficients by wavelet decomposition. But I don't know how to make the figure. I use an old version Matlab (7.0) with wavelet toolbox but no new functions like wpspectrum. So is there a way for me to make the figure? I understand that color scale indicates magnitude of the coefficients at each frequency-time block. I use the code below to acquire detail coefficients D1 - D8:
s=mysignal; %256 elements, Fs = 1Hz.
numlevels = wmaxlev(length(s), 'haar');
[C,L]= wavedec(s, numlevels, 'haar');
D1 = detcoef(C,L,1); D2 = detcoef(C,L,2); D3 = detcoef(C,L,3); D4 = detcoef(C,L,4); D5 = detcoef(C,L,5); D6 = detcoef(C,L,6); D7 = detcoef(C,L,7); D8 = detcoef(C,L,8);
[Ea,Ed] = wenergy(C,L);
%Make sure these two values are equal:
sum(D1.^2)+sum(D2.^2)+sum(D3.^2)+sum(D4.^2)+sum(D5.^2)+sum(D6.^2)+sum(D7.^2)+sum(D8.^2)+C(1)^2
sum(s.^2)

 Accepted Answer

Hi Shinchin, A couple things.
In your call to detcoef(), it is better to use.
dcell = detcoef(C,L,'cells');
to get all the detail coefficients with one line.
If you want to separate out your wavelet coefficients in approximate passbands, you can use the following approximation (which is not very good with the Haar wavelet by the way).
At level J, the wavelet coefficients approximate the output of a bandpass filter with passband [Fs/(2^(J+1)), Fs/2^J]
but you will have to space your wavelet coefficients correctly.

1 Comment

Hi Wayne, Thanks for your help. How do I create a plot like figure 2 in this, given that I have the coefficients:
http://www.amara.com/IEEEwave/IW_wave_vs_four.html
with color scale indicating the magnitude of each coefficient in each time-frequency tile?

Sign in to comment.

More Answers (1)

Hi Wayne, Thank you very much for your suggestions. It cleans up my code a lot and put all the coefficients in one cell. But now I still face with the question of miking a figure. I know what passband and time resolutions are for each coefficient. But how do I make the frequency vs. time figure?

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!