close all clear all clc x = [-1,3,-5,2]; nx = -1:2; g = [1,2,-1]; ng = 0:2; y = conv(x,g); ny = [nx(1)+ng(1):nx(end)+ng(end)]; figure subplot(2,2,1) stem(nx,x) grid xlabel('n') ylabel('x(n)') subplot(2,2,2) stem(ng,g) grid xlabel('n') ylabel('g(n)') subplot(2,1,2) stem(ny,y) grid xlabel('n') ylabel('y(n)=x*g(n)') sgtitle('discrete-time convolution') % printing figure in png format set(gcf,'PaperUnits','inches','PaperPosition',[0 0 4 3]) print -dpng exercise1.png -r100