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

Assignment 4

This document provides instructions for a MATLAB assignment on plotting and analyzing signals. Students are asked to: 1. Make plots of various continuous and discrete-time signals using the plot and stem commands. This includes sinusoidal, step, impulse and sampled signals. 2. Generate common discrete-time sequences like unit impulse and sinusoidal signals using MATLAB commands. 3. Compute and plot convolutions of given signals using the conv command to observe relationships between input and output signals. 4. Comment on observations like how signals change when convolved with themselves repeatedly.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

Assignment 4

This document provides instructions for a MATLAB assignment on plotting and analyzing signals. Students are asked to: 1. Make plots of various continuous and discrete-time signals using the plot and stem commands. This includes sinusoidal, step, impulse and sampled signals. 2. Generate common discrete-time sequences like unit impulse and sinusoidal signals using MATLAB commands. 3. Compute and plot convolutions of given signals using the conv command to observe relationships between input and output signals. 4. Comment on observations like how signals change when convolved with themselves repeatedly.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Signals and Systems

Lab no 2 : Basic plotting of Signals


Instructions:

You need to submit assignment in a word/pdf file containing question wise codes and screen shots of
outputs from MATLAB where required

This is a group assignment with a group of 3 students each, deadline for submission is 17 Jan 2022

Using MATLAB, make plots of the signals below. Put your code in a MATLAB script file so you can
rerun it from the MATLAB command after you make revisions to your file.
Use the subplot command to put several plots on the same page. Print out the plots and turn them
in with your code. Use help subplot to find out how to use the command.
Use the plot command to plot continuous-time signals. Use the stem command to plot
discrete- time signals. Use help plot and help stem to find out how to use these commands. Our
convention is that f (t) denotes a continuous-time signal, and that f (n) denotes a discrete-time signal.

1. Plotting Continuous-Time Signals


For the following: Run the following three lines and explain why the plots are different.

t = 0 : 2*pi; plot( t , sin(t) )


t = 0 : 0.2 : 2*pi; plot( t , sin(t) )
t = 0 : 0.02 : 2*pi; plot( t , sin(t) )

For the last graph, add a title and axis labels with:

title ( ‘My Favorite Function’ )


xlabel ( ‘t (Seconds)’ )
ylabel ( ‘y(t)’ )

Change the axis with:

axis ( [0 2*pi -1.2 1.2] )

Put two plots on the same axis:

t = 0 : 0.2 : 2*pi ; plot ( t , sin(t) , t , sin(2*t) )

Produce a plot without connecting the points:

t = 0 : 0.2 : 2*pi ; plot ( t , sin(t) , ‘.’)

1
EE-232 Signals and Systems
Try the following command:
t = 0 : 0.2 : 2*pi ; plot( t , sin(t) , t , sin(t) , ’r.’)
What does the r do?
2. Plotting Discrete-Time Signals
Use stemto plot the discrete-time step-function:
n = -10:10;
f = n >= 0;
stem ( n , f )
Make stem plots of the following signals. Decide for yourself what the range of n should be.
f (n) = u(n) − u(n − 4)
g(n) = n · u(n) − 2 (n − 4) · u(n − 4) + (n − 8) · u(n − 8)
x(n) = δ(n) − 2 δ(n − 4)
y(n) = (0.9)n (u(n) − u(n − 20))
v(n) = cos(0.12 πn) u(n)

3. Generation of Sequences
Following are some of the commonly used discrete time signals generated using MATLAB
Unit impulse and unit step sequences
A unit impulse sequence of length N can be generated in MATLAB by the following command
u = [1 zeros(1,N -1)];
A unit impulse sequence delayed by M samples where M < N can be generated as follows
ud = [zeros(1,M) 1 zeros(1,N-M- 1)];
Likewise, a unit step sequence s[n] of length N can be generated using the MATLAB command
s = [ones(1,N)];
A delayed unit step sequence can be generated in a manner similar to that used in the generation
of a delayed unit sample sequence.
Program P3_1 can be used to generate and plot a unit impulse sequence.
% Program P1_1
% Generation of a Unit Sample Sequence
clear all
close all
clc
% Generate a vector from -10 to 20
n = -10:20;
% Generate the unit sample
% sequence
u = [zeros(1,10) 1 zeros(1,20)];
% Plot the unit sample sequence

2
EE-232 Signals and Systems
stem(n,u);
xlabel('Time index n');ylabel('Amplitude');
title('Unit Sample Sequence');
axis([-10 20 0 1.2]);
grid on;

Sinusoidal sequences
Sinusoidal sequences can be generated in MATLAB using “sin” and “cos” functions. Program
P1_1.1 is a MATLAB code that generates a sinusoidal signal.
% Program P1_1.1
% Generation of a sinusoidal sequence
clear all; close all; clc;
n = 0 : 40 ;
f = 0.1 ;
phase = 0 ;
A = 1.5 ;
arg = 2 * pi * f * n – phase ;
x = A*cos(arg) ;
stem(n,x,'r'); % Plot the generated sequence
axis ([0 40 -2 2]) ;
grid ;
title ('Sinusoidal Sequence') ;
xlabel ('Time index n') ;
ylabel ('Amplitude') ;

4. Plotting a Sampled-Signal.
Suppose the continuous-time signal x(t) is sampled with a sampling period of 0.3 seconds
between each sample. Suppose also that the first sample is at t = 0 and that a total of 12 samples
are collected. The table below lists the samples of x(t) that were collected.

sample number x(t)


0 6.0
1 -1.3
2 -8.0
3 -11.7
4 -11.0
5 -6.0
6 1.3
7 8.0
8 11.7
9 11.0
10 6.0

3
EE-232 Signals and Systems
11 -1.3

Using the plot command, make a plot of this signal. The horizontal axis should be labeled: TIME
(SECONDS). Make sure that the horizontal time axis shows the correct time for each sample:
0, 0.3, 0.6, . . . , 3.3.

5. The conv Command


Use help conv to find out how to use the conv command.
Let
f (n) = u(n) − u(n − 4)

g(n) = n · u(n) − 2 (n − 4) · u(n − 4) + (n − 8) · u(n − 8).

Make stem plots of the following convolutions. Use the MATLAB convcommand to compute
the convolutions.

(a) f (n) ∗ f (n)


(b) f (n) ∗ f (n) ∗ f (n)
(c) f (n) ∗ g(n)
(d) g(n) ∗ δ(n)
(e) g(n) ∗ g(n)
Comment on your observations: Do you see any relationship between f (n) ∗ f (n) and g(n) ?
Compare f (n) with f (n) ∗ f (n) and with f (n) ∗ f (n) ∗ f (n). What happens as you repeatedly
convolve this signal with itself?
Use the commands title, xlabel, ylabel to label the axes of your plots.

4
EE-232 Signals and Systems

You might also like