Buscar

lab 4

Esta é uma pré-visualização de arquivo. Entre para ver o arquivo original

# Lab 4
import numpy as np
import matplotlib.pylab as plt
x = np.array([0, 1, 2, 3, 0, 0,])
h1 = np.array([1, 1, 1, 1, 1, 0,])
y1 = np.convolve(x, h1)
h2 = np.array([0, 0, 1, 1, 1, 1,])
y2 = np.convolve(x, h2)
#plt.stem(np.arange(0,11),y1,'b')
#plt.stem(np.arange(0,11),y2,'r')
plt.stem(np.arange(0,11),y1+y2); plt.title('Sist. Paralelo')
# 1) Demonstre com simulações computacionais (gráficos) que a convolução é distributiva. 
# Distributividade
h3 = h1 + h2
y3 = np.convolve(x,h3)
plt.figure()
plt.stem(np.arange(0,11),y3); plt.title('Sist. Paralelo Equiv.')
# 2) Demonstre com simulações computacionais (gráficos) que a convolução é associativa
# Associatividade
x2 = np.convolve(x,h1)
y4 = np.convolve(x2,h2)
plt.figure()
plt.stem(np.arange(0,16),y4); plt.title('Sist. Cascata')
h4 = np.convolve(h1,h2)
y5 = np.convolve(x,h4)
plt.figure()
plt.stem(np.arange(0,16),y5); plt.title('Sist. Cascata Equiv.')
#3) Demonstre com simulações computacionais (gráficos) que a convolução é comutativa. 
# Comutatividade
h5 = np.convolve(h2,h1)
y6 = np.convolve(x,h5)
plt.figure()
plt.stem(np.arange(0,16),y6); plt.title('Sist. Cascata Equiv.')

Teste o Premium para desbloquear

Aproveite todos os benefícios por 3 dias sem pagar! 😉
Já tem cadastro?

Outros materiais