Matlab, 145 2
Matlab, 145 2
Registration Number
FA19-BEE-145/ISB
Class
SIGNAL & SYSTEM (BEE-4C)
Instructor’s Name
SIR.KHURAM SHEHZAD
Gggggggggggggggggggggggggggggggggggggg
Page 2 of 10
Figure: 2.1
Page 3 of 10
In-Lab Task:
Task 02: Make a function ‘my_sum’ which takes two vectors x and y as input. The vectors
should have different sizes. Firstly, make size of both the input vectors same by padding
(concatenating) zeros. Now add both the vectors element wise. The function should return a
variable z which should contain the sum of all the elements of the vectors formed as a result of
summation of input vectors x and y.
Figure:1.1
OUTPUT:
Figure:1.2
Task 03: Write MATLAB programs to find the following with for loops and vectorization. Time
both versions in each case.
Page 4 of 10
a) 1 2 + 2 2 + 3 2 + 4 2 + ⋯ + 10002
For Loops:
Vectorization:
Figure:1.3
For Loops:
Figure:1.6
Vectorization:
Figure:1.4
Task 04: Graph the following function in MATLAB over the range of 0 to 10.
Page 6 of 10
0, (𝑠𝑖𝑛(𝑥) ≤ 0)
Figure:1.5
Task 05: Use the semi log graph to graph 𝑥 2 , 𝑥 3 , 𝑥 4𝑎𝑛𝑑 𝑒 𝑥 2 over the interval of 0 ≤ 𝑥 ≤
2𝜋.
Page 7 of 10
Figure: 1.7
Task 06: Plot the first ten cycles of sinusoid (sin) with time period of 2 seconds. The
horizontal axis corresponds to time period of the sinusoid while vertical axis depicts the values
of sinusoid.
Figure:1.8
Page 8 of 10
Horizontal axis corresponds to instances n and vertical axis depicts 𝑥[𝑛] values.
Figure:1.9
Page 9 of 10
Task 08: 𝑥(𝑡) = 𝐴 ℝ{𝑒 𝑗(𝜔0𝑡+𝜑) } Where A = 1, f0 = 10 Hz, 𝜑 = 0 Plot the second and third
harmonics of the above sinusoid. Use SUBPLOT command for drawing in the same manner as in
previous question. After plotting explain the relation of fundamental Time period and
harmonics Time period clearly. Your answer should corroborate the graphs drawn.
Figure:2.0
Page 10 of 10
Discussion:
In this lab we discuss that
1. The code for function and trigonometric logarithmic and simple function
2. The continuous and discrete signal for function
Conclusion:
In this lab, we conclude that.
1. we learn how to make function and call-in different script or in command window.
2. We make functions by using If else, for loop and make functions to plot a graph of
discrete functions, Sine functions and exponential functions.