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

Report 2

This lab report describes plotting various functions of signals x(t) and y(t). The report includes Python code to generate the signals, perform operations on them such as addition and multiplication, and plot the results. Functions plotted include x(t)+y(t), x(t)-y(t), x(t)*y(t), x(t)/2 + y(t)/3, x(-t), y(-t), x(2t), and x(-2t+5).

Uploaded by

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

Report 2

This lab report describes plotting various functions of signals x(t) and y(t). The report includes Python code to generate the signals, perform operations on them such as addition and multiplication, and plot the results. Functions plotted include x(t)+y(t), x(t)-y(t), x(t)*y(t), x(t)/2 + y(t)/3, x(-t), y(-t), x(2t), and x(-2t+5).

Uploaded by

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

SIGNAL AND SYSTEM LAB REPORT - 2

NAME – Manish Kumar Jaiswal


Roll No – 21CS8053
Plot the following functions: -
x(t) = 1, 5>t ≥ 0
= 2, 8>t ≥ 5
= 5,12>t≥8
= 0,t<0 or t>12
y(t) = 2, 7>t ≥ 0
= 0, 10>t ≥ 7
= 7,15>t≥10
= 0,t<0 or t>15
a. x(t) + y(t)

import numpy as np

import matplotlib.pyplot as plt

t = range(-20, 20, 1)

x_t = []

y_t = []

f_t = []

for i in range(len(t)):

temp = (1 if (t[i]>=0 and t[i]<5) else 2 if (t[i]>=5 and t[i]<8) else 5 if (t[i]>=8 and t[i]<12) else 0)

x_t.append(temp)

for i in range(len(t)):

temp = (2 if (t[i]>=0 and t[i]<7) else 7 if (t[i]>=10 and t[i]<15) else 0)

y_t.append(temp)

z_t = []

for i in range(len(x_t)):

s = x_t[i] + y_t[i]

z_t.append(s)

#plotting the graph

plt.plot(t, z_t)

plt.xlabel('t -->')
plt.ylabel('x(t)+y(t) -->')

plt.title('Waveform')

plt.grid()

plt.show()

b. x(t)-y(t)
import numpy as np

import matplotlib.pyplot as plt

t = range(-20, 20, 1)

x_t = []

y_t = []

f_t = []

for i in range(len(t)):

temp = (1 if (t[i]>=0 and t[i]<5) else 2 if (t[i]>=5 and t[i]<8) else 5 if (t[i]>=8 and t[i]<12) else 0)

x_t.append(temp)

for i in range(len(t)):

temp = (2 if (t[i]>=0 and t[i]<7) else 7 if (t[i]>=10 and t[i]<15) else 0)

y_t.append(temp)

z_t = []

for i in range(len(x_t)):

s = x_t[i] - y_t[i]
z_t.append(s)

#plotting the graph

plt.plot(t, z_t)

plt.xlabel('t -->')

plt.ylabel('x(t)-y(t) -->')

plt.title('Waveform')

plt.grid()

plt.show()

c. x(t)*y(t)
import numpy as np

import matplotlib.pyplot as plt

t = range(-20, 20, 1)

x_t = []

y_t = []

f_t = []

for i in range(len(t)):

temp = (1 if (t[i]>=0 and t[i]<5) else 2 if (t[i]>=5 and t[i]<8) else 5 if (t[i]>=8 and t[i]<12) else 0)

x_t.append(temp)

for i in range(len(t)):
temp = (2 if (t[i]>=0 and t[i]<7) else 7 if (t[i]>=10 and t[i]<15) else 0)

y_t.append(temp)

z_t = []

for i in range(len(x_t)):

s = x_t[i] * y_t[i]

z_t.append(s)

#plotting the graph

plt.plot(t, z_t)

plt.xlabel('t -->')

plt.ylabel('x(t)*y(t) -->')

plt.title('Waveform')

plt.grid()

plt.show()

d. x(t)/2+y(t)/3
import numpy as np

import matplotlib.pyplot as plt

t = range(-20, 20, 1)

x_t = []

y_t = []
f_t = []

for i in range(len(t)):

temp = (1 if (t[i]>=0 and t[i]<5) else 2 if (t[i]>=5 and t[i]<8) else 5 if (t[i]>=8 and t[i]<12) else 0)

x_t.append(temp)

for i in range(len(t)):

temp = (2 if (t[i]>=0 and t[i]<7) else 7 if (t[i]>=10 and t[i]<15) else 0)

y_t.append(temp)

z_t = []

for i in range(len(x_t)):

s = x_t[i]/2 + y_t[i]/3

z_t.append(s)

#plotting the graph

plt.plot(t, z_t)

plt.xlabel('t -->')

plt.ylabel('x(t)/2+y(t)/3 -->')

plt.title('Waveform')

plt.grid()

plt.show()

e. x(-t)
import numpy as np

import matplotlib.pyplot as plt

t = range(-20, 20, 1)

x_t = []

y_t = []

f_t = []

for i in range(len(t)):

temp = (1 if (t[i]>=0 and t[i]<5) else 2 if (t[i]>=5 and t[i]<8) else 5 if (t[i]>=8 and t[i]<12) else 0)

x_t.append(temp)

for i in range(len(t)):

temp = (2 if (t[i]>=0 and t[i]<7) else 7 if (t[i]>=10 and t[i]<15) else 0)

y_t.append(temp)

z_t = []

for i in range(len(x_t)):

s = x_t[-i]

z_t.append(s)

#plotting the graph

plt.plot(t, z_t)

plt.xlabel('t -->')

plt.ylabel('x(-t) -->')

plt.title('Waveform')

plt.grid()

plt.show()
f. y(-t)
import numpy as np

import matplotlib.pyplot as plt

t = range(-20, 20, 1)

x_t = []

y_t = []

f_t = []

for i in range(len(t)):

temp = (1 if (t[i]>=0 and t[i]<5) else 2 if (t[i]>=5 and t[i]<8) else 5 if (t[i]>=8 and t[i]<12) else 0)

x_t.append(temp)

for i in range(len(t)):

temp = (2 if (t[i]>=0 and t[i]<7) else 7 if (t[i]>=10 and t[i]<15) else 0)

y_t.append(temp)

z_t = []

for i in range(len(x_t)):

s = y_t[-i]

z_t.append(s)

#plotting the graph

plt.plot(t, z_t)

plt.xlabel('t -->')

plt.ylabel('y(-t) -->')

plt.title('Waveform')

plt.grid()

plt.show()
g. x(2t)
import numpy as np
import matplotlib.pyplot as plt
t = range(-20, 20, 1)
x_t = []
y_t = []
f_t = []
for i in range(len(t)):
temp = (1 if (t[i]>=0 and t[i]<5) else 2 if (t[i]>=5 and t[i]<8) else 5 if (t[i]>=8 and t[i]<12) else 0)
x_t.append(temp)
for i in range(len(t)):
temp = (2 if (t[i]>=0 and t[i]<7) else 7 if (t[i]>=10 and t[i]<15) else 0)
y_t.append(temp)
z_t = []
t_t = range(-20,20,2)
for i in range(len(t_t)):
s = x_t[i*2]
z_t.append(s)
#plotting the graph
plt.plot(t_t, z_t)
plt.xlabel('t -->')
plt.ylabel('x(2t) -->')
plt.title('Waveform')
plt.grid()
plt.show()

h. x(-2t+5)
import numpy as np

import matplotlib.pyplot as plt

t = range(-20, 20, 1)

x_t = []

y_t = []

f_t = []

for i in range(len(t)):

temp = (1 if (t[i]>=0 and t[i]<5) else 2 if (t[i]>=5 and t[i]<8) else 5 if (t[i]>=8 and t[i]<12) else 0)

x_t.append(temp)

for i in range(len(t)):

temp = (2 if (t[i]>=0 and t[i]<7) else 7 if (t[i]>=10 and t[i]<15) else 0)

y_t.append(temp)

z_t = []

t_t = range(-20,20,2)

for i in range(len(t_t)):

s = x_t[-i*2+5]

z_t.append(s)

#plotting the graph

plt.plot(t_t, z_t)

plt.xlabel('t -->')

plt.ylabel('x(-2t+5) -->')

plt.title('Waveform')

plt.grid()

plt.show()

You might also like