Report 2
Report 2
import numpy as np
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)):
y_t.append(temp)
z_t = []
for i in range(len(x_t)):
s = x_t[i] + y_t[i]
z_t.append(s)
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
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)):
y_t.append(temp)
z_t = []
for i in range(len(x_t)):
s = x_t[i] - y_t[i]
z_t.append(s)
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
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)
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
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)):
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)
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
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)):
y_t.append(temp)
z_t = []
for i in range(len(x_t)):
s = x_t[-i]
z_t.append(s)
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
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)):
y_t.append(temp)
z_t = []
for i in range(len(x_t)):
s = y_t[-i]
z_t.append(s)
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
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)):
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)
plt.plot(t_t, z_t)
plt.xlabel('t -->')
plt.ylabel('x(-2t+5) -->')
plt.title('Waveform')
plt.grid()
plt.show()