Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

NAME : RONTALA AJAY REDDY

ROLL NUMBER : 21CS8105

REGISTRATION NUMBER : 21U10420

SECTION : Y

ASSIGNMENT –
01
PLOTTING THE FOLLLOWING FUNCTIONS

1) Unit step function :

CODE:

import numpy as np
import matplotlib.pyplot as plt
xpoints=[i for i in range(-100,100)]
ypoints=[]
for i in xpoints:
if i>=0:
ypoints.append(1)
else:
ypoints.append(0)
plt.title("unit step function")
plt.plot(xpoints,ypoints,'o')
plt.show()

OUTPUT:
2) Unit impulse function :
CODE :
import numpy as np
import matplotlib.pyplot as plt
xpoints=[i for i in range(-40,40)]
ypoints=[]
for i in xpoints:
if i==0:
ypoints.append(1)
else:
ypoints.append(0)
plt.title("unit impulse function")
plt.plot(xpoints,ypoints,'o')
plt.show()

OUTPUT :
3) Ramp function :

CODE:

import numpy as np
import matplotlib.pyplot as plt
xpoints=[i for i in range(-100,100)]
ypoints=[]
for i in xpoints:
if i>=0:
ypoints.append(i)
else:
ypoints.append(0)
plt.title("ramp function")
plt.plot(xpoints,ypoints,'o')
plt.show()

OUTPUT:
4) PERIODICAL SINUSOIDAL SEQUENCE :

a) y = sin(wt)
CODE:

import matplotlib.pyplot as plt import numpy


as np import random f=int(input("Enter the
time period:")) x=np.arange(0,10,0.01)
y=np.cos((x*np.pi*2)/f) plt.plot(x,y)
plt.show()

Enter the time period:4

OUTPUT :
b) y = sin(wt+Q) (where Q is phase difference)
CODE :

import matplotlib.pyplot as plt import numpy as


np import random f=int(input("Enter the time
period:")) i=float(input("Enter the phase
change:")) x=np.arange(0,10,0.01)
y=np.sin(((x*np.pi*2)/f)+i*np.pi) plt.plot(x,y)
plt.show()

Enter the time period:5


Enter the phase change:5

OUTPUT :

You might also like