Assignment 4
Assignment 4
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.
For the last graph, add a title and axis labels with:
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.
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.
Make stem plots of the following convolutions. Use the MATLAB convcommand to compute
the convolutions.
4
EE-232 Signals and Systems