Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
40 views14 pages

S S.Lab.3

The document outlines an experiment focused on observing and plotting continuous and discrete time signals using MATLAB. It covers various types of signals including impulse, step, ramp, sinusoidal, triangular, sawtooth, and exponential sequences, providing examples of MATLAB code for generating and plotting these signals. The learning outcomes include understanding the differences between continuous and discrete signals and the use of plotting functions in MATLAB.

Uploaded by

Usama Javed
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)
40 views14 pages

S S.Lab.3

The document outlines an experiment focused on observing and plotting continuous and discrete time signals using MATLAB. It covers various types of signals including impulse, step, ramp, sinusoidal, triangular, sawtooth, and exponential sequences, providing examples of MATLAB code for generating and plotting these signals. The learning outcomes include understanding the differences between continuous and discrete signals and the use of plotting functions in MATLAB.

Uploaded by

Usama Javed
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/ 14

EXPERIMENT NO.

3
OBJECTIVE:
Observing continuous and discrete time signals and plotting basic sequences using MATLAB.

LEARNING OUTCOME:
In this lab, students will be able to understand:
• Plotting Continuous and Discrete Time signals
• Generation of Impulse Sequence
• Generation of Step Sequence
• Generation of Ramp Sequence
• Generation of Sinusoidal Sequence
• Generation of Triangular Sequence
• Generation of Saw tooth Sequence
• Generation of Exponential sequences.

1. INTRODUCTION:
In this lab we will study about two different types of signals Continuous-Time Signals and
Discrete-Time Signals. We will also study about Impulse, ramp, and step sequences. We will
see how we can plot Sine, Exponential, and Saw tooth signals.

2. SIGNALS AND THEIR TYPES:


Signals are represented mathematically as functions of one or more independent variables. Here
we focus attention on signals involving a single independent variable. For convenience, this
will generally refer to the independent variable as time.
There are two types of signals: Continuous-time signals and Discrete-time signals.

Continuous-time signal: the variable of time is continuous. A speech signal as a function of


time is a continuous-time signal.

Discrete-time signal: the variable of time is discrete. The weekly Dow Jones stock market
index is an example of discrete-time signal.
Example 1:
Plot continuous Sine wave using MATLAB:
Code:
n = 0:1:50;
z = sin(n/4);
plot(n,z);
title('Continous Sinewave')
xlabel ('time')
ylabel ('sin(n/4)')
Output:

Example 2:
Plot discrete Sine wave using MATLAB:
Code:
n=0:2:60;
y=sin(n/6);
subplot(3,1,1)
stem(n,y)
title('Discrete-time function');
xlabel('n');
ylabel('sin(n/6)');
Output:
Example 3:
Explain the difference in terms of function and syntax in between Stem and Plot
command.
Function:
Plot display the continuous values of the curves.
Stem display the discrete values the points on the curves.
Plot creates a 2-D line plot of the data in Y versus the corresponding values in X.
Stem plots the data sequence, Y, at values specified by X.
Syntax:
Syntax of both plot and stem are same only the name difference mean keywords
>> Plot(X,Y)
>>Stem(X,Y)

3. UNIT IMPULSE SIGNAL:


The impulse response is generally a short duration time domain signal. A system’s impulse
response (often annotated as h(t) for continuous – time system ) or (h[n] for discrete – time
system ) is defined as the output signal that results in when impulse is applied. Impulse function
is a function that is zero everywhere but at the origin, where it is infinity high. However the
area of impulse is finite. The unit impulse has area = 1, which shows its height.
Example 4:
Generate a unit impulse sequence.
Code:
n = -5:10;
I =[zeros(1,5) 1 zeros(1,10)];
stem(n,I);
title('Unit Impulse Sequence')
xlabel('Time')
ylabel('Amplitude')
axis([-5 10 0 2])
Output:

4. UNIT STEP SEQUENCE:


The unit step function, usually denoted by u, is a discontinuous function whose value is zero
for negative argument and one for positive argument. The function is used in the mathematics
of control theory and signal processing to represent a signal that switches on at a specified time
and stays switched on indefinitely. Mathematically, a continuous time unit step function is
written as.

In discrete form, a unit step function can be mathematically written as

Graphically, unit step sequence is shown in figure below:


Example 5:
Generate a unit step response sequence using MATLAB.
Code:
n = -5:10;
I =[zeros(1,5) 1 ones(1,10)];
stem(n,I);
title('Unit Impulse Sequence')
xlabel('Time')
ylabel('Amplitude')
axis([-5 10 0 2])
Output:

5. RAMP SEQUENCE:
The unit ramp function R(x), is a ramp function with a constant slope of 1. Widely used in
signal processing, the function forms a building block for more complex signals.

Graphically, unit step sequence is shown in figure below:


Example 6:
Generate a unit ramp response sequence using MATLAB.
Code:
n = -5:10;
ramp = n.* (n>=0);
stem(n,ramp, 'fill');
title('Unit Impulse Sequence')
xlabel('Time')
ylabel('Amplitude')
Output:

6. CREATION OF REAL EXPONENTIALS:


Another basic discrete-time sequence is the exponential sequence. Such a sequence can be
generated using the MATLAB.
Code:
n =0: 0.1:1;
x = -10*n;
stem(n,x);
title('Exponential Sequence');
xlabel('Time');
ylabel('Amplitude');
Output:

7. Creation of Complex Exponentials:


Code:
n=0:20
w=pi/6;
x=exp (j*w*n)
subplot(2,1,1);
stem(n,real(x));
xlabel(‘Time index n’);
ylabel(‘Amplitude’);
title(‘Real part’);
subplot (2,1,2);
stem (n,imag(x));
xlabel(‘Time index n’);
ylabel(‘Amplitude’);
title (‘Imaginary part’);
Output:
Lab Task 1:
Write a program in MATLAB to generate Saw tooth Waveform.
Code:
n = 0:100;
z = sawtooth(n/2);
plot(n,z);
title(' Sawtooth wave')
xlabel ('time')
ylabel ('sawtooth(n/2)')
Output:

Lab Task 2:
Write a program in MATLAB to generate a Triangular Pulse
Code:
t=0:0.1:50;
x=sawtooth(t,0.5);
plot(t,x)
title(' Triangular pulse')
xlabel ('time')
Output:

Lab Task 3: Generate following signals:

Lab Task 3(a):


t=0:2:34;
x=sin((pi/17)*t);
subplot(312)
stem(t,x)
title(' Discrete time wave')
xlabel ('time')
ylabel('sin((pi/17)*t)')

Output:
Lab Task 3(b):
t=-17:2:17;
x=sin((pi/17)*t);
subplot(312)
stem(t,x)
title(' Discrete time wave')
xlabel ('time')
ylabel('sin((pi/17)*t)')

Output:
Lab Task 4:

a. Create 𝒙[𝒏] = 𝒆(𝒋∗𝒏/𝟑) for some range and see its real and imaginary parts
separately

Code for (a):


n=0:20
x=exp (j*(n/3))
subplot(2,1,1);
stem(n,real(x));
xlabel('Time index n');
ylabel('Amplitude');
title('Real part');
subplot (2,1,2);
stem (n,imag(x));
xlabel('Time index n');
ylabel('Amplitude');
title ('Imaginary part');
Output:
b. Make the following signals; plot their real and imaginary parts on the same figure.
What difference do you notice between the two signals?

Code for (b):

n=-10:0.1:10
x1=exp ((-0.1+j*0.3)*n)
subplot(2,2,1);
plot(n,real(x1));
xlabel('Time index n');
ylabel('Amplitude');
title('Real part of x1');
subplot (2,2,2);
plot (n,imag(x1));
xlabel('Time index n2');
ylabel('Amplitude');
title ('Imaginary part of x1');
x2=exp ((0.1+j*0.3)*n)
subplot(2,2,3);
plot(n,real(x2));
xlabel('Time index n');
ylabel('Amplitude');
title('Real partof x2');
subplot (2,2,4);
plot (n,imag(x2));
xlabel('Time index n');
ylabel('Amplitude');
title ('Imaginary part of x2');

Output:
Explanation:
In my opinion the only diff is the sign of the real part of the complex number in
the equation. Due to the changing in the real part the second graph is inverted and the imaginary
part is 90-degree phase shift. If the value of ‘i’ is negative then the phase shift will be -90-
degree.
Discussion and Conclusion:
In the lab, we discuss the concepts of the continuous and discrete
time signals and used the plot and stem keywords for wave graph.
stem is used for the plot the discrete time signal graph.
A continuous-time signal has values for all points in time in some (possibly infinite) interval.
It is an analog representation of natural signals. It is defined over a finite or infinite domain of
sequence. These are described by the differential equation. The value of signal can be
obtained at any arbitrary point of signal.
A discrete time signal has values for only discrete points in time. The value of signal can be
obtained at sampling instant of time. It is defined over a finite domain of sequence. The
discrete time signal is digital representation of a continuous time signal.

You might also like