From: Mike Gagliardo on
First, thanks for posting the cascade algoritm, it is exactly what I needed. It took me a bit to figure out how it works, especially since I am just getting into Wavelets and Matlab. Here is what I understand so far:

> >%Filter coefficients for daub4 (h<->scaling, g<->wavelet)
> >h = [1+sqrt(3) 3+sqrt(3) 3-sqrt(3) 1-sqrt(3)]/(4*sqrt(2));
> >g = [h(4) -h(3) h(2) -h(1)];

Just as the note says, these are the Filter coefficients. From what I can tell, the High pass and low pass operators applied to the signal coefficients the appropriate number of times will give you the wavelet coefficients. However, there are also dual operators that go in the other direction. So given the wavelet coefficients and applying the dual high and low pass operators enought times we get the signal (which can be thought of as the graph)

The formula for the Dual High and Low pass operators is exactly the convolution operation in this program.
s=conv(x,cs);
w=conv(x2,cs);
The book I am reading, "Discovering Wavelets" has this formula on page 74. One drawback of this cascade file is that the resulting scaling function is NOT defined on [0,3]. I made some adjustments which are listed below in the cascadeg.m file. The function below returns 3 variables, the scaling function, the wavelet function and the appropriate t to graph against. So plot(t,s) will give you the scaling function on 0 to 3 with the appropriate values.

Again, I am really a wavelet novice, so I hope this is all correct.
--------------------

function [ s,w,t ] = cascadeg(n,cs,cw)
s=cs;
w=cw;
x2(1:2:length(w)*2)=w;
x2(2:2:end)=0;
x(1:2:length(s)*2)=s;
x(2:2:end)=0;

for i = 1:n

s=conv(x,cs);
w=conv(x2,cs);

x2(1:2:length(w)*2)=w;
x2(2:2:end)=0;
x(1:2:length(s)*2)=s;
x(2:2:end)=0;

end
t=0:3/(length(s)-1):3;
s=s*(sum(s));
end