in command window; %part a) n=-10:1:10; subplot(3,1,1) stem(stepDT(n)) subplot (3,1,2) stem(stepDT(n-3)) subplot(3,1,3) y1=conv(stepDT(n), stepDT(n-3)) stem(y1, 'g') %part b) n=-10:1:10; subplot (3,1,1) stem(((1/2).^n).*stepDT(n-2)) subplot (3,1,2) stem(stepDT(n)) subplot (3,1,3) y2=conv(((1/2).^n).*stepDT (n-2), stepDT (n)) stem(y2, 'm') %part c) n=-10:1:10; subplot (3,1,1) stem((-1).^n) subplot(3,1,2) stem ( (2.^n).* (stepDT (-1* n+2) )) subplot (3,1,3) y3=conv((-1).^n, (2.^n).* (stepDT(-1*n+2))) stem(y3, 'm') %part d) t=-10:1:10; subplot(3,1,1) plot(u(t)-u(t-2)) subplot(3,1,2) plot(u(t)) subplot (3,1,3) y4=conv(u(t)-u(t-2),u(t)) plot (y4, 'c') %part e) t=-10:1:10; subplot(3,1,1) plot(exp(-1*t).*u(t)) subplot(3,1,2) plot(exp(-3*t).*u(t)) subplot(3,1,3) y5=conv(exp(-1*t).*u(t), exp (-3*t).*u(t)) plot (y5, 'y') % Easy way clear all clc n=-10:1:10; x=[1 0 2 3 4 -1 0 2]; h=[1 0 0 -1 -2 1]; y1=conv(x,h) % Detailed way clear all clc x=[1 0 2 3 4 -1 0 2]; x_=x; h=[1 0 0 -1 -2 1]; h_=h; m=zeros(length(x)+length(h)-1); for i=1:length(h) for j=1:length(x) m(i,j)=x(j) end x=[0 x] end for i=1:length(h) k(i,:)=h(i)*m(i,:) end sum(k) subplot (3,1,1) stem(x_) title('Function x') grid on subplot (3,1,2) stem(h_) title( 'Function h') grid on subplot (3,1,3) stem (sum (k) ) title ('Convolution of x and h') grid on % Continuous Time Convolution clear all clc t = -10:0.01:10; x = (t >= -1 & t < 2); y = (t >= 1 & t < 2); subplot(3,1,1) plot(t, x) title('Function x') subplot(3,1,2) plot(t, y) title('Function y') subplot(3,1,3) plot(conv(x, y)) title('Convolution function of x and y')