0% found this document useful (0 votes)
76 views

Ss Lab 2

This document describes a lab experiment on generating discrete time signals in MATLAB. The objectives are to understand discrete time signals and generate common signals like impulse, step, and sinusoidal waves. It discusses the basic concepts of discrete time signals and their mathematical representations. The lab tasks involve writing MATLAB code to generate unit impulse, unit step, and sinusoidal signals with various amplitudes and frequencies. The document provides example MATLAB code and output for each signal. It also lists exercises for students to generate shifted versions of impulse and step signals, and a sinusoidal signal that takes the amplitude as input from the user.

Uploaded by

AaqibR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views

Ss Lab 2

This document describes a lab experiment on generating discrete time signals in MATLAB. The objectives are to understand discrete time signals and generate common signals like impulse, step, and sinusoidal waves. It discusses the basic concepts of discrete time signals and their mathematical representations. The lab tasks involve writing MATLAB code to generate unit impulse, unit step, and sinusoidal signals with various amplitudes and frequencies. The document provides example MATLAB code and output for each signal. It also lists exercises for students to generate shifted versions of impulse and step signals, and a sinusoidal signal that takes the amplitude as input from the user.

Uploaded by

AaqibR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Mehran University of Engineering and Technology, SZAB Campus, Khairpur Mir’s

Department of Electrical Engineering


Signals & Systems
Lab #02

Name: Roll No:

Score: Signature: Date: ______________

Generation of Discrete Time Signals


OBJECTIVES:

Following are the objectives of this lab.


 To understand the basic concept of discrete time signals.
 To generate and plot the different discrete time signals using MATLAB.

EQUIPMENT:

 IBM compatible computer


 MATLAB

DISCUSSION:

INTRODUCTION:

Analog Signal Processing deals with the processing of continuous time signals whereas in
Digital Signal Processing we study discrete-time discrete-valued signals processed by
digital computers or other data processing machines. First step in going from analog to
digital is ‘sampling’. It is the reduction of a continuous signal to a discrete signal. A
common example is the conversion of a sound wave (a continuous-time signal) to a
sequence of samples (a discrete-time signal). If the amplitude of a DT signal is also made
discrete through the process of ‘quantization’ or rounding off, then it becomes a Digital
Signal.
In this lab, we will learn to generate unit sample, unit step and sinusoidal signals using
MATLAB.
Impulse:
the simplest signal is the unit impulse signal which is as δ (n) =

as δ (n) = 1 for n = 0
= 0 for n ≠ 0
Unit Step:
the general form of step function is
u (n) = 1 for n ≥ 0
= 0 for n< 0.

Sinusoid:
x(n) Asin(n )
where, 2f
n = integer variable called the sample number,
A = amplitude of the sinusoid,
= frequency in radians per sample,
= phase in radians.

Exponential:
The decaying exponential is a basic signal in DSP. Their general form is given by x (n) = an for
all n

Ramp
The signal is given by u (n) = n for n ≥ 0

LAB TASK:
Generation of Unit Impulse (n) :
Consider the following code:
n=-1:10;
s=[0 1
zeros(1,10)];
stem(n,s);
xlabel('n');
ylabel('Amplitude');
title('unit sample
sequence'); axis([-10 20 0
1]);
OR
%% Generation of a Unit Impulse
n=-2:10; %Generate the sample index vector
imp=n==0; %Set the sample at zero index equal
to 1 stem(n,imp); %Plot the impulse signal
xlabel('Samples'); %Give label to x-axis
ylabel('Amplitude'); %Give label to y-axis
title('Unit Impulse Signal (\delta(n))');
grid; %Show grid in figure
Its output is as follows

Generation of Unit Step signal u(n)


Consider the following code:
a=-10:20;
b=[zeros(1,10) 1 ones(1,20)];
stem(a,b);
OR
%% Generation of the Unit step Signal
n=-2:10; %Generate the sample index vector
step=n>=0; %Set the samples at sample index greater than
or equal to zero to 1
stem(n,step); %Plot the step signal
xlabel('Samples'); %Give label to x-axis
ylabel('Amplitude'); %Give label to y-axis
title('Unit Step Signal (u(n))'); %Give title to the plot
grid; %Show grid in figure
Its output is as follows,

Generation of Sinusoidal Signal:


Consider the following code:

c=0:40;
freq=.1;
phase=0;
amp=2;
arg=2*pi*freq*c+phase;
ans=amp*cos(arg);
stem(c,ans);
axis([0 40 -3 3]);
gridon;
title('cosine');
xlabel('time index');
ylabel('amplitude');
Its output is as follow,

1. Write a program to generate(n5).

2. Write a program to generate u(n2).


(Use ‘xlable’, ‘ylabel’, ‘title’ functions in your code. See MATLAB help for
syntax)

3. Write a program to generate a sine wave with any suitable frequency. Your code
should ask for the amplitude of the sine wave as an input from theuser.
(Use ‘input’ function. Please see MATLAB help for syntax)
1. Write a program to generate a sine wave with any suitable frequency. Your code
should ask for the amplitude of the sine wave as an input from the user.
(Use ‘input’ function. Please see MATLAB help for syntax)

Final Check List:

 Save your programs & turn off PC.


 Submit your answers to questions, and results before the next laboratory.

You might also like