1
$\begingroup$

http://en.wikipedia.org/wiki/Daubechies_wavelet#Transform.2C_D4

I find it is difficult to understand the pseudo-code on this Wiki page.

N = length(S); s1 = S(1:2:N-1) + sqrt(3)*S(2:2:N); d1 = S(2:2:N) - sqrt(3)/4*s1 - (sqrt(3)-2)/4*[s1(N/2); s1(1:N/2-1)]; s2 = s1 - [d1(2:N/2); d1(1)];<<<<<<<<<<<<<<<<<<<<<<< s = (sqrt(3)-1)/sqrt(2) * s2; d = (sqrt(3)+1)/sqrt(2) * d1; 

I do not understand what does the square-bracket means.

  • 1
    I think the best way to understand the code is to implement it in Matlab. Can you do that?2011-06-20

2 Answers 2

3

The pseudo code is heavily using Matlab syntax. The square brackets mean concatenation of vectors. In this case you take the vector d1 (which is supposed to be a row vector), extract the second to N/2the entries and put the first entry of d1 below these.

2

To complement Dirk's answer, note that:
S(1:2:N-1) selects the 1st, 3rd and N-1 rows of the column vector, S.
s1(N/2) selects the N/2 row of s1 whereas s1(1:N/2-1) selects the 1st and N/2-1 rows of s1.

Hope this helps.