0% found this document useful (0 votes)
56 views10 pages

Matlab, 145 2

This lab report discusses signal plotting and basic MATLAB programming. It includes 8 tasks: 1) plotting an exponential-sine function, 2) making a function to sum vectors of different sizes, 3) using for loops and vectorization to calculate sums and series, 4) graphing a piecewise function, 5) using semi-log graphing, 6) plotting sinusoidal cycles, 7) plotting discrete sequences, and 8) plotting harmonics of a sinusoid. Figures generated from the tasks are included on pages 3 through 10. The conclusion states that the lab taught how to make functions using if/else statements, for loops, and how to plot different types of signals and functions in MATLAB.

Uploaded by

Muneeb ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views10 pages

Matlab, 145 2

This lab report discusses signal plotting and basic MATLAB programming. It includes 8 tasks: 1) plotting an exponential-sine function, 2) making a function to sum vectors of different sizes, 3) using for loops and vectorization to calculate sums and series, 4) graphing a piecewise function, 5) using semi-log graphing, 6) plotting sinusoidal cycles, 7) plotting discrete sequences, and 8) plotting harmonics of a sinusoid. Figures generated from the tasks are included on pages 3 through 10. The conclusion states that the lab taught how to make functions using if/else statements, for loops, and how to plot different types of signals and functions in MATLAB.

Uploaded by

Muneeb ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Page 1 of 10

Name Muneeb Ahmad

Registration Number
FA19-BEE-145/ISB

Class
SIGNAL & SYSTEM (BEE-4C)

Instructor’s Name
SIR.KHURAM SHEHZAD

Gggggggggggggggggggggggggggggggggggggg
Page 2 of 10

Lab report #02


Title: Signal Plotting and Basic Programming
Pre-Lab:
Task 01: Plot a function 𝑒 −0.2𝑥 𝑠𝑖𝑛(𝑥) between the interval 0 𝑡𝑜 6𝜋 .

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

b) 1 – 1/3 + 1/5 – 1/7 + 1/9 − ⋯ ⋯ − 1/1003


Page 5 of 10

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, (𝑠𝑖𝑛(𝑥) ≤ 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

Task 07: Plot the following discrete sequences.


a. 𝑥[𝑛] = 𝛼 𝑛 0 ≤ 𝑛 ≤ 10, 𝛼 = 1.5

b. 𝑥[𝑛] = 𝛽 𝑛 − 10 ≤ 𝑛 ≤ −1, 𝛽 = 1.5

c. 𝑥[𝑛] = 𝛾 𝑛 0 ≤ 𝑛 ≤ 10, 𝛾 = 0.5

d. 𝑥[𝑛] = 𝜑 𝑛 − 10 ≤ 𝑛 ≤ −1, 𝜑 = 0.5

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 and CONCLUSION:

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

Proof of discussion: 1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1

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.

You might also like