Code3301
<?xml encoding="utf-8" ?><p>clc; clear all; close all;</p><p>% part a - generation of discrete time signals</p><p>% unit impulse</p><p>n=-10:10;</p><p>x1=(n==0);</p><p>subplot (2,3,1)</p><p>stem(n,x1); xlabel('n --->'); ylabel('x1(n)');title('Unit Impulse')</p><p>% unit step</p><p>u=(n>=0);</p><p>subplot(2,3,2)</p><p>stem(n,u);</p><p>axis([-10 10 -2 2]); xlabel('n --->'); ylabel('u(n)'); title('Unit Step')</p><p>% unit ramp</p><p>r = u.*n; % unit ramp = unit step * t</p><p>subplot(2,3,3)</p><p>stem(n,r); xlabel('n --->'); ylabel('r(n)'); title('Unit Ramp')</p><p>% unit parabolic</p><p>p = 0.5*(n.^2).*u;</p><p>subplot(2,3,4)</p><p>stem(n,p); xlabel('n --->'); ylabel('p(n)'); title('parabolic')</p><p>% exponential</p><p>%a = 0.5;</p><p>%a = -0.5;</p><p>a = 2; %constant</p><p>x2 = a.^n);</p><p>subplot(2,3,4)</p><p>stem(n,x2); xlabel('n --->'); ylabel('x2(n)'); title('exponential')</p><p>% sinusoidal</p><p>f1 = 0.05; %frequency in Hz</p><p>x3 = sin(2*pi*f1*n);</p><p>subplot(2,3,5)</p><p>stem(n,x3); xlabel('n --->'); ylabel('x3(n)'); title('sinusoidal')</p>