cons_c = [1+sqrt(3), 3+sqrt(3), 3-sqrt(3), 1-sqrt(3)]/4;
cons_w = [-(sqrt(3)-1), 3-sqrt(3), -(3+sqrt(3)), 1+sqrt(3)]/4;
iters = 4;
f = ones(1,50);
points = 100;
length_f = 50;
for iter = 0:iters
step_size = points*2^(iter-1);
temp_t = 0:1/((2^iter)*points):4;
temp_cf = zeros(size(temp_t));
temp_wf = zeros(size(temp_t));
for l = 0:3
temp_cf(l*step_size+1:length_f+l*step_size) = cons_c(l+1)*f(1:length_f) +...
temp_cf(l*step_size+1:length_f+l*step_size);
end
f = temp_cf;
for l2 = 0:3
temp_wf(l2*step_size+1:length_f+l2*step_size) = cons_w(l2+1)*f(1:length_f) +...
temp_wf(l2*step_size+1:length_f+l2*step_size);
end
length_f = find(f==0, 1)-1;
subplot(2, 1, 1)
plot(temp_t, f)
title("Daubechies 2 Scaling Function: iter", iter+1)
xlabel("t")
ylabel("\phi(t)")
subplot(2, 1, 2)
plot(temp_t, temp_wf)
title("Daubechies 2 Wavelet Function: iter", iter+1)
xlabel("t")
ylabel("\psi(t)")
pause(1)
end