# Hints and helps to implement an accurate wavelet packet transfrom

I want to implement a Time-Freqency analysis by wavelet packets. I don't know what level and sampling rate should I use. I've tried different value for level(3,4,5,6,). but I couldn't get an accurate frequency identification. here is my little scrip and results, hope one can say whats the problem, Thanks in advance.

f=30;N=300;                            %df:final time,N:segments
t=linspace(0,df,N); dt=t(3)-t(2);      % dt: time intervals
fs=ceil(inv(t(2)-t(1)));              % fs: sampling freq
fn=[0.4 0.6 1.0];E=[0.03 0.05 0.1];   %fn:freq, E:damping
A=[1.0 2.0 3.0];wn=2*pi.*fn;a=E.*wn;wd=wn.*sqrt(1-E.^2);  % A:Amplitude.
y=A(1)*exp(-a(1)*t).*sin(wd(1)*t)+A(2)*exp(-a(2)*t).*...
sin(wd(2)*t)+A(3)*exp(-a(3)*t).*sin(wd(3)*t);
level = 3;
wpt = wpdec(y,level,'coif5');
[Spec,Time,Freq] = wpspectrum(wpt,fs,'plot');


here are result for Level 3,4,5,6 decompositions.

as you can see in the pictures, It doesn't show fn=[0.4 0.6 1.0] values accurately. Then I have run another little scrip to see which frequencies,WP identified.

absSpec=abs(Spec);
modI=max(absSpec');          % get  max |Spec| correspond to freq of signal
modI=modI/max(modI);         % normalize each column 0-1
fig=1;fig=fig+1;figure(fig)
Freq=fliplr(Freq);            % the frequency order must be reverse. idk why, i fount-
% out by trail and error. very strange but true.
plot(Freq,modI)              % Plot all modes(freq).
grid on


Here is the frequency plot for level 3,4,5,6.

As you can see it doesn't show [0.4,0.6,1]Hz frequencies at level 3,4,5. but in level 6 it shows something(why?). but not accurate though. it represent a range of frequency specially for 0.6 and 1 Hz.(the peak is flat) why this is happening?
moreover, I got the plot for level 8,9,10,11 too. in here I can see a better results, but still it represent 2 or more peaks for each frequencies(why?)(plot is small here so you may barely see it).

so my questions are:

1. what sampling rate($f_s$)should i select in this case?(now it's 10)
2. why frequency plot doesn't show any result in level 3,4,5?
3. It shows some result in level 6 for all frequencies. but what is its range? I can understand it is representing a range of frequencies for every components(0.4,0.6,1Hz) of my signal. Afterward, what is the error for detected range in this level(or any level)?
4. In level 8,9,10,11 frequency plot has a narrower range so its more accurate, but what is other smaller peaks around detected frequencies?
5. for a time series with size of M what is WPT computational complexity in terms of big O(), I thought its faster than CWT but it is definitely not (I just can feel it by Tic_Toc function). so would anyone compare WPT with CWT in computational complexity (big O) terms?