0% found this document useful (0 votes)
34 views8 pages

Exp 2

The document discusses different types of discrete time signals that can be represented in MATLAB, including unit sample sequences, unit step sequences, real and complex exponential sequences, and sinusoidal sequences. Examples of MATLAB code are provided to generate signals of each type and plot them.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views8 pages

Exp 2

The document discusses different types of discrete time signals that can be represented in MATLAB, including unit sample sequences, unit step sequences, real and complex exponential sequences, and sinusoidal sequences. Examples of MATLAB code are provided to generate signals of each type and plot them.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Digital signal processing lab

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] ,…....}

Where the up-arrow indicates the sample at n=0.


In MATLAB, we can represent a finite-duration sequence like above by a row
of vector of appropriate values. However such a vector does not have any
information about sample position n. therefore a correct representation of x[n]
would require two vectors, one each for x and n. for example a signal
X[n] = {2,1,-1,0,1,4,3}
>>n=[-3,-2,-1,0,1,2,3];
>>x=[2,1,-1,0,1,4,3];
An arbitrary infinite duration signal cannot be represented by MATLAB
due to finite memory limitations

Basic Signals:

Unit Sample Sequenc

>>function[x, n] =impseq (n0, n1, n2)


% Generates x[n] =delta (n-n0) ; n1<=n<=n2

% n1 is lower limit of required sequence;n2 is upper limit of required sequence


>>n=n1:n2;x=(n-n0)==0;
>>stem(n,x);
>>title(‘Delayed Impulse’);
>>xlabel(‘n’);
>>ylabel(‘x[n]’);

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)

% Generates x[n] =u (n-n0) ; n1<=n<=n2

% n1 is lower limit of required sequence;n2 is upper limit of required sequence

>>n=n1:n2;x=(n-n0)>=0;

>>stem(n,x);

>>title(Delayed Step Sequence);

>>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)

title(’Delayed Step Sequence’)

xlabel(’n’)

ylabel(x[n]);

PLOT:
Real-valued Exponential Sequence

X[n] = an

In MATLAB, we can write


>>n=0:10; x=(0.9).^n

MATLAB RESULT OF ABOVE COMMAND:

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

Complex-valued Exponential Sequence

X[n] = e(a+jw0)n , for all n

MATLAB function exp is used to generate exponential sequences. For example


to generate
X[n]=exp[(2+3j)n],0<=n<=10, we can write:
>>n=0:10;x=exp((2+3j)*n)

MATLAB RESULT OF ABOVE COMMAND:

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

-0.0183 - 0.0317i -0.0000 - 0.0222i 0.0067 - 0.0117i

PLOT:
Sinusoidal sequence:

X[n]= cos(won+ θ),for all n

Matlab function sin or cos is used to generate 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

You might also like