%% =================================================================
%% DIFERENTES CONVOLUCIONES CON UNA ONDICULA DE ENTRADA
%%
%% !OBS: El directorio debe contener la ondícula "wavelet"
%% =================================================================

clear ; % Limpio variables
clf ;   % Limpio figuras

load wavelet ;        % Cargo la ondicula
w = [wavelet(1:16)] ; % Trunco y me quedo con las primeras 16 muestras
w = w/max(abs(w)) ;   % Normalizo

% Defino las series dadas en el enunciado
a = [1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0] ;
b = [0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0] ;
c = [1.0,-1.0,0.0,0.0,0.0,0.0,0.0,0.0] ;
d = [0.0,0.0,0.0,0.0,1.0,-1.0,0.0,0.0] ;

% Hago las convoluciones con w
wa = conv(w,a) ;
wb = conv(w,b) ;
wc = conv(w,c) ;
wd = conv(w,d) ;

% Agrego ceros para que me queden a, b, c, y d de tamaño 16 
a(16) = 0 ;
b(16) = 0 ;
c(16) = 0 ;
d(16) = 0 ;

% Ondicula original
subplot(5,2,2)
stem(w,'ro')
axis([0.8,16.2,-1.2,1.2])
text(15.0,0.8,'w')

% Función Delta
subplot(5,2,3)
stem(a,'g-o')
axis([0.8,16.2,-1.2,1.2])
text(15.0,0.8,'a')

% Convolución con la función Delta
subplot(5,2,4)
stem((1:16),wa(1:16),'bo')
axis([0.8,16.2,-1.2,1.2])
text(14.5,0.8,'w*a')

% Función Delta retardada
subplot(5,2,5)
stem(b,'g-o')
axis([0.8,16.2,-1.2,1.2])
text(15.0,0.8,'g')

% Convolución con la función Delta retardada
subplot(5,2,6)
stem((1:16),wb(1:16),'bo')
axis([0.8,16.2,-1.2,1.2])
text(14.5,0.8,'w*b')

% Operador derivada
subplot(5,2,7)
stem(c,'g-o')
axis([0.8,16.2,-1.2,1.2])
text(15.0,0.8,'c')

% Convolución con el operador derivada
subplot(5,2,8)
stem((1:16),wc(1:16),'bo')
axis([0.8,16.2,-1.2,1.2])
text(14.5,0.8,'w*c')

% Operador derivada retrasado
subplot(5,2,9)
stem(d,'g-o')
axis([0.8,16.2,-1.2,1.2])
text(15.0,0.8,'d')

% Convolución con el operador derivada retrasado
subplot(5,2,10)
stem((1:16),wd(1:16),'bo')
axis([0.8,16.2,-1.2,1.2])
text(14.5,0.8,'w*d')

% Guardo el gráfico en un archivo
print('convoluciones.eps','-depsc')
