n = -30:30; wo = pi/5; x = sin(wo*n)./(pi *n); x(n==0) = wo/pi; % L'Hospital's rule stem(n,x); grid title('x[n] = [sin(\pi n/5)]/(\pi n)'); ylabel('x[n]');
n = -20:20; x = zeros(size(n)); x((n>=-1)&(n<=3)) = 1; x(n==4) = 1/2; subplot(321) stem(n,x) grid axis([-10 10 0 1.5]); title('x[n]'); subplot(322) na = n+2; stem(na,x); grid axis([-10 10 0 1.5]); title('x[n-2]'); subplot(323) nb = 4-n; stem(nb,x); grid axis([-10 10 0 1.5]); title('x[4-n]'); subplot(324) nc = -10:10; % x goes from -20:20, so y will go from -10:10 for k=-10:10 % (e.g., y[10] = x[20]) y(nc==k) = x(n==(2*k)); end stem(nc,y); grid axis([-10 10 0 1.5]); title('x[2n]'); subplot(325) y = x.*((2-n)>=0); stem(n,y); grid axis([-10 10 0 1.5]); title('x[n] u[2-n]'); subplot(326) ne = n+1; y = x.*(ne == 3); stem(ne,y); grid axis([-10 10 0 1.5]); title('x[n-1] \delta[n-3]');
%(a) subplot(311) n=0:40; x = (0.9).^n .* cos(0.1*pi*n+pi/5); stem(n,x); grid ylabel('x[n]'); title('x[n] = 0.9^n cos(0.1 \pi n + \pi/6)'); %(b) subplot(312) n=0:40; x = (0.9).^n .* cos(4.1*pi*n+pi/5); stem(n,x); grid xlabel('n'); ylabel('x[n]'); title('x[n] = 0.9^n cos(4.1 \pi n + \pi/6)'); %(c) subplot(313) n=-10:10; x=(0.75).^n .* (((n+6)>=0) - ((n-5)>=0)) + 5*(n==2); stem(n,x); grid xlabel('n'); ylabel('x[n]'); title('x[n] = 0.75^n (u[n+6] - u[n-5]) + 5 delta[n-2]');
subplot(321) n = -20:20; x = (n>=0) - ((n-4)>=0); stem(n,x); grid axis([-10 10 -4 4]) title('x[n] = u[n] - u[n-4]');
subplot(322) y = n.*x; stem(n,y); grid axis([-10 10 -4 4]) title('y[n] = n x[n]');
subplot(323) stem(n+2,y) grid axis([-10 10 -4 4]) title('y[n-2]');
subplot(324) n1 = n+2; x1 = x; stem(n1,x1); grid axis([-10 10 -4 4]) grid title('x1[n] = x[n-2]');
subplot(325) y1 = n1.*x1; stem(n1,y1); grid axis([-10 10 -4 4]) grid title('y1[n]');
subplot(321) n = -30:30; x = (n>=0) - ((n-4)>=0); stem(n,x); grid axis([-10 10 0 1.5]) title('x[n] = u[n] - u[n-4]');
subplot(322) ny=-15:15; for k=-15:15 y(ny==k) = (x((n+1)==k) + x(n==k) + x((n-1)==k))/3; end stem(ny,y); grid axis([-10 10 0 1.5]) title('y[n] = (x[n+1] + x[n] + x[n-1])/3');
subplot(323) stem(ny+2,y) grid axis([-10 10 0 1.5]) title('y[n-2]');
subplot(324) n1 = n+2; x1 = x; stem(n1,x1); grid axis([-10 10 0 1.5]) title('x1[n] = x[n-2]');
subplot(325) ny1 = -15:15; for k=-15:15 y1(ny1==k) = (x((n1+1)==k) + x(n1==k) + x((n1-1)==k))/3; end stem(ny1,y1); grid axis([-10 10 0 1.5]) title('y1[n]');