% file: task15.m
% MA-5

h  = (1/5) * ones(5,1); % impulse response h[n] of MA-5
y3 = conv(h, y);        % convolution for h and y
figure(1); clf;
plot(t, y, 'b', t, y2, 'k', t, y3(1:length(y)), 'r');
grid on; xlabel('time (s)');
legend({'Orig.','MA-2','MA-5'});

figure(2); clf;
freqz(h,1);   % amplitude + phase response
figure(3); clf;
[H,w] = freqz(h,1); 
plot(w, abs(H)); % amplitude response in linear y-scale