You are on page 1of 13

DEPARTMENT OF COMPUTER &

SOFTWARE ENGINEERING
COLLEGE OF E&ME, NUST, RAWALPINDI

Signals and Systems

Lab Number # 02

SUBMITTED BY:
Muhammad Umer Naeem
359091

Submission Date: 10/11/2022


Objectives: The objective of this lab is to create an understanding of using
loops and conditional statements in MATLAB. It also introduces the basics of
plotting signals

Task 1:

Using For Loop:


Using while Loop:
Using If Loop:
Task 2:

Code:

Both commands will initialize the H, but the output of the first command will be
different because the values are initialized in the loop and displayed. Whereas in
the second command first vector H is created and then multiplied by the scalar
5.But the values stored will be same after execution of the commands
(b)
In the first command the values are initialized in the variable x after taking
the sin of the values in the loop therefore the initialized values in the x is
displayed in the loop whereas in the second command ,first the vector is
being created and then sin of all the elements in the vector is taken. After the
execution of both commands the values stored in the vector will be the same
but the output will be difficult.
Task 3:.
• These lines are plotted in the different way because the distribution of the points
along the X-Axis(time) is different. The plot t=0:2*pi; plot(t, sin(t)) contains the points
from 0->2pi but the difference between the points is of 1 unit so the plot is not
smooth, Whereas the plot t=0:0.2:2*pi;plot(t, sin(t)) contains the points having the
difference of 0.2 unit which contains the more distribution of the points as compared
to the other one and having more uniform smooth plot.
The third plot t=0:0.02:2*pi; plot(t, sin(t)) is having the difference of 0.02 between
the points and the plot is the most smoothest as compared to the others due to
having more points

Task 4:
---(Produce a plot without connecting the points)---
This command will print the two same plots on same figure and on same plot
but it will print the plot of the second command in “Red Color” with “dot(.)
Marker”

You might also like