Generation of elementary signal in python

from matplotlib import pyplot as pltplt.style.use('ggplot')xval = [x for x in range(-100,100)]yval=[]for t in range(-100,100):
if t==0:
yval.append(1) else: yval.append(0)plt.plot(xval,yval,label="delta function")plt.xlabel("time")plt.ylabel("Amplitude")plt.grid(True)plt.legend()plt.show()
Delta function
from matplotlib import pyplot as pltplt.style.use('ggplot')x_val = [x for x in range(-100,100)]y_val =[]for x in x_val:      if x>=0:         y_val.append(1)      else:         y_val.append(0)plt.plot(x_val,y_val,color='g',label="Step signal")plt.legend()plt.title("step signal")plt.xlabel('time')plt.ylabel('amp')plt.show()
Step Function
from matplotlib import pyplot as pltplt.style.use('ggplot')x_val = [x for x in range(-50,50)]y_val=[]for x in x_val:      if x>=0:         y_val.append(1)      else:         y_val.append(-1)plt.stem(x_val,y_val,label="signum function")plt.legend()plt.title("Signum Function")plt.xlabel("Time")plt.ylabel("Amplitude")plt.show()
Signum Function
from matplotlib import pyplot as pltimport numpy as npplt.style.use('ggplot')x_val = np.arange(-np.pi,np.pi,0.5)y_val = [np.sin(x) for x in x_val]plt.plot(x_val,y_val,color='g',label="sine wave")plt.legend()plt.title("Sine wave")plt.xlabel("Time")plt.ylabel("Amplitude")plt.show()
Sine wave
from matplotlib import pyplot as pltimport numpy as npplt.style.use('ggplot')x_val = np.arange(0,4*np.pi,0.5)y_val = [np.cos(i) for i in x_val]plt.plot(x_val,y_val,label="cos wave")plt.legend()plt.title("Cos wave")plt.xlabel("Time")plt.ylabel("Amplitude")plt.grid(True)plt.tight_layout()plt.show()
cosine
from matplotlib import pyplot as pltplt.style.use('ggplot')x_val = [x for x in range(-10,100)]y_val=[]t=0for x in x_val:      if x>=0:         y_val.append(t*1)         t+=1     else:         y_val.append(0)plt.plot(x_val,y_val,label="Ramp signal")plt.legend()plt.xlabel("Amplitude")plt.ylabel("Time")plt.title("Ramp signal")plt.show()

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

The Unsexy Data Science : Cleaning and Labeling Data

CS371p Fall 2020 Week 4: Darshan Bhatta

Scope of Log analytics in Telecom

7 real-world applications of reinforcement learning

A DIY Reddit sentiment analyzer (of meme stocks)

Life started late…… But it’s rocking😊

Poisson distribution explained

Conversion Rate Optimization Minidegree — CXL Institute Review #10

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nilay Paul

Nilay Paul

More from Medium

How I was checking to tell if there was convergence in my simulations.

Editbox multiple lines gui

Python for loop

Draw Circle — Diameter, Radius, Arc and Segment Using Python Matplotlib Module