You are on page 1of 4

EEL715

Laboratory 0 Date: 01-01-2019

Instructions for the Lab :

1. All the exercises in the Lab should be solved individually.


2. If you want to explore more about a particular function in the Matlab, you can always use the help options
in Matlab and there are lot of online resources for Matlab

Exercise: 1

Note : Refer to the functions mesh(), plot(), sin(), sind(), figure() using the help menu

 The plot command in Matlab helps to plot the Vector of data. There are a various lot of options
that can be possible with the plot commands. [Matlab being a very sophisticated GUI tool all plot
modifications are possible through the figure window]. Here in this exercise we focus our
attention on two-dimensional plots. For the following: Run the following three lines and try to
figure out why the plots are different.

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

For the last graph, add a title and axis labels with:
d) title('My Favorite Function');
xlabel('t(seconds)')
ylabel('y(t)')

Change the axis with:


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

Put two plots on the same axis:


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

Produce a plot without connecting the points:


g) t=0:0.2:2*pi; plot(t,sin(t),'.')
Change the ‘.’ parameter to ‘r’ in the above plot command. Also try changing that to some other
parameter. Use the Matlab help to understand what other parameters can be changed using the plot
commands. Try to modify the same options through the Figure window in Matlab.

Notes:
All the above commands can be typed as it is in the Matlab Command window. The presence of the
plot statement opens a figure window with x and y axes. All the above commands which modify the
properties of the Figure window is also possible through
the GUI options in the Figure window itself.

1|Page
EEL715
Laboratory 0 Date: 01-01-2019

The above picture shows one of the screen captures of the Figure window. The properties of this
window can be modified by changing the Edit  Axes properties and also through the other set of
options in the Insert menu. Try changing a few options like Inserting the labels, title, changing the
plot color, adding legends, changing the range of the axes etc., through the Figure window also.

Exercise: 2

Note : Refer to the functions flip(), sum( ), abs(), linspace() using the help menu

Generate the following vectors using the Colon operator and also using the linspace command and use
the above functions.
a) F=[1 2 3 4 ..... 30]
b) G=[25 22 19 16 13 10 7 4 1]
c) [0 0.2 0.4 0.6 ....... 2.0]
Notes:
linspace (X1, X2, N) generates N points between X1 and X2.
For N < 2, linspace returns X2.
Other way of creating a sequence is using the colon operator. It should be of the form [start:
increment: end].

Exercise: 3

2|Page
EEL715
Laboratory 0 Date: 01-01-2019

Note : Refer to the functions eig(),det(),trace() using the help menu

The Matlab function eig returns the eigenvalue of a square matrix M, det its determinant and trace
its trace.
a. Find the Eigen values, determinant and trace of the matrix M.
b. Find the product and sum of the eigenvalues of

Exercise 4

Given that, y = Asin(2πf t + φ) + B, generate a sine wave given the following specifications: A = 5 , f = 2 Hz
, φ = π/8 radians and B = 2.5. Plot the above signal with the following values of fs: 1 Hz, 10 Hz, 100 Hz.

Exercise 5

Create a signal equal to the sum of two sine waves with the following characteristics:
(a) 3-second duration
(b) Sampling frequency = 2 kHz
(c) Sinusoid 1: frequency 50 Hz (low), amplitude 10, phase = 0
(d) Sinusoid 2: frequency 950 Hz (high), amplitude 1, phase = 0
Use fs = 10000 Hz.

Exercise 6

Determine 𝑦[𝑛] = 𝑥[𝑛] ⨂ ℎ[𝑛] where x[n] and h[n] are


𝑛2 + 1, 0 ≤ 𝑛 ≤ 3
𝑥[𝑛] = { and
0, 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
𝑛 + 1, 0 ≤ 𝑛 ≤ 3
ℎ[𝑛] = {
0, 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
Use conv () to perform the above operation. Verify the your results

Exercise 7

(a) Generate a noisy sine wave: frequency = 1650 Hz, max amplitude =1 and noise variance as 0.01.
Assume a sampling frequency of fs = 10000 Hz

This signal is passed through the system described as follows: LTI system with difference equation of
𝑦[𝑛] = 0.5𝑦[𝑛 − 1] + 𝑥[𝑛]𝑥[𝑛 − 1]

(b) Obtain the output using filter ().


(c) Obtain the impulse response of system, impz ().
(d) Obtain the output using the conv () operator
(e) Compare the two output (b) and (d) and how do the methods (filter and conv) differ?
(f) Compute the frequency response of the LTI system specified above.

3|Page
EEL715
Laboratory 0 Date: 01-01-2019

Exercise 8
Plot the frequency responses of the two filters with the following difference equations. Use sampling
frequency = 2kHz.
(a) Low-pass: y[n] = 0.5x[n] + 0.5x[n − 1] (averaging)
(b) High-pass: y[n] = 0.5x[n] − 0.5x[n − 1] (finite differencing)
(c) For both the cases plot the magnitude of the frequency response in dB and on the same figure plot
the phase response.

4|Page

You might also like