% Nada Amin
% 6.003 Problem Set 2, Problem 9, BDS 2.2

% a
a1 = [1];
b1 = [0.5 1 2];

% b
a2 = [1 -0.8];
b2 = [2 0];

% c
a3 = [1 -0.8];
b3 = [0 2];

% d
x = [1 2 3 4];
y1 = filter(b1,a1,x)
y2 = filter(b2,a2,x)
y3 = filter(b3,a3,x)

% e
x = [1 1 1 1 1 1];
h = [0:5];

% f
y = filter(h,1,x);
ny = [0:5];
stem(ny,y);

% g
x2 = [1 1 1 1 1 1 0 0 0 0 0];
y2 = filter(h,1,x2);
stem([0:10],y2);

% h
% h.i
h2 = h;
y2 = filter(h2,1,x);
ny2 = [0:5] - 5;
stem(ny2,y2)
% h.j
h2 = h;
y2 = filter(h2,1,x2);
ny2 = [0:10] - 5; 
stem(ny2,y2)
