addpath('toolbox_signal');
addpath('toolbox_general');
N=512;
name='piece-regular';
f=rescale(load_signal(name,N));
A=f(1:N);
L=log2(N)-1;
clf;
subplot(L+1,1,1);
plot(f);
axis('tight');
title('Signal');

B=0;
for i=0:L
    A=f(1:fix(N/2^i));
    Coarse=(A(1:2:length(A))+A(2:2:length(A)))/sqrt(2);
    Detail=(A(1:2:length(A))-A(2:2:length(A)))/sqrt(2);
    A=[Coarse;Detail;B];
    subplot(L+1,1,i+1);
    plot(A);
    axis('tight');
    title(strcat('Haar sur un niveau ',num2str(i)));
    B=[Detail;B];
end

figure,
plot(A>0.02);