Exp 2
Exp 2
Exp. No.2
Introduction to different types of discrete time signals and
their plotting
Introduction:
Discrete time signals are defined only at certain specific values of time. They
can be represented by x[n] where ‘n’ is integer valued and represents discrete
instances in time. i.e:
X[n] = {….., x[-1], x[0] ,x[1] ,…....}
Basic Signals:
Practice:
Use above function to plot unit sample sequence that has a value at n=-9 in a
range fro n=-14 to n=-2. Use zeros(1,N) command to generate above unit
sample sequence function…
MATLAB CODE:
>> n0=-9;
>> n1=-14;
>> n2=-2;
>> n=n1:n2;
>> x=(n-n0)==0;
>> stem(n,x)
>> title('Delayed Impulse Sequence')
>> xlabel('n')
>> ylabel('x[n]')
PLOT:
Unit step sequnce
>>function[x, n] =stepseq (n0, n1, n2)
>>n=n1:n2;x=(n-n0)>=0;
>>stem(n,x);
>>xlabel(n);
>>ylabel(x[n]);
Practice:
Use above function to plot unit step sequence having range between -5 and 15, shifted at n=-3.
Use zeros(1,N) and ones(1,N) commands to generate above unit step sequence function
MATLAB CODE:
n0=-3;
n1=-5;
n2=15;
n=n1:n2;
x=(n-n0)>=0;
stem(n,x)
xlabel(’n’)
ylabel(x[n]);
PLOT:
Real-valued Exponential Sequence
X[n] = an
x=
Columns 1 through 7
1.0000 0.9000 0.8100 0.7290 0.6561 0.5905 0.5314
Columns 8 through 11
0.4783 0.4305 0.3874 0.3487
x=
1.0e+008 *
Columns 1 through 4
0.00 -0.00+0.00i 0.00-0.00i -0.00+0.00i
Columns 5 through 8
0.00-0.00i -0.0002+0.0001i 0.0011-0.0012i -0.0066+0.0101i
Columns 9 through 11
0.0377-0.0805i -0.1918+0.6280i 0.7484-4.7936i
Practice:
Generate a complex exponential given below in MATLAB and also plot the
output
X[n] = 2e(-0.5+(π/6)j)n
MATLAB CODE:
>> n=0:10;
a=2;
b=exp((-0.5+(pi/6)*j)*n);
x=a*b
plot(n,x)
MATLAB RESULT:
x=
Columns 1 through 4
2.000 1.050 +0.606i 0.367 +0.637i 0.000 +0.446i
Columns 5 through 8
-0.135 +0.234i -0.142 +0.082i -0.099 +0.000i -0.052 -0.030i
Columns 9 through 11
PLOT:
Sinusoidal sequence:
Practice:
Generate a sinusoidal signal given below in MATLAB and also plot the output
>>x[n]=3cos(0.1nπ+π/3)+2sin(0.5nπ )
MATLAB CODE:
>>n=0:10;
a=3*cos((0.1*n*pi)+pi/3);
b=2*sin(0.5*n*pi);
x=a+b;
plot(n,x)
plot
Eng/Abdulsalam alhaboob