#
# PYTHON • MyCompiler
#
# Gráfico Convolução
# https://[Log in to view URL]
# Gráfico Convolução
#
# 2026 Outubro Sex, 2
# 2026 Outubro Ter, 6
#
# by
# j
#

import numpy as np
import matplotlib.pyplot as plt

# Definição dos sinais

x = [2, 4, 8, 4, 2]

h3 = [1/3, 1/3, 1/3] 
h5 = [1/5, 1/5, 1/5, 1/5, 1/5] 
h7 = [1/7, 1/7, 1/7, 1/7, 1/7, 1/7, 1/7] 
h9 = [1/9, 1/9, 1/9, 1/9, 1/9, 1/9, 1/9, 1/9, 1/9 ]

g = [ 1/256, 8/256, 28/256, 56/256, 70/256, 56/256, 28/256, 8/256, 1/256 ]

y3 = np.convolve(x, h3, mode='full')
y5 = np.convolve(x, h5, mode='full')
y7 = np.convolve(x, h7, mode='full')
y9 = np.convolve(x, h9, mode='full')

yg = np.convolve(x, g, mode='full')

# Criação dos eixos de tempo (índices)
n_x = np.arange(len(x))
n_3 = np.arange(len(y3))
n_5 = np.arange(len(y5))
n_7 = np.arange(len(y7))
n_9 = np.arange(len(y9))
n_g = np.arange(len(yg))

# Configuração da figura
plt.figure(figsize=(10, 10))

# Plot do Sinal de Entrada (x)
plt.subplot(3, 2, 1)
plt.stem(n_x, x, linefmt='b-', markerfmt='bo', basefmt='k-')
plt.title('Sinal de Entrada x[n]')
plt.xlabel('Amostras (n)')
plt.ylabel('Amplitude')
plt.grid(True)
plt.xticks(n_x)

# 
# Plot do Sinal de Saída Convolved (y3)
#

plt.subplot(3, 2, 2)
plt.stem(n_3, y3, linefmt='r-', markerfmt='ro', basefmt='k-')
plt.title('Sinal de Saída y3[n] (mode=\'full\')')
plt.xlabel('Amostras (n)')
plt.ylabel('Amplitude')
plt.grid(True)
plt.xticks(n_3)

# 
# Plot do Sinal de Saída Convolved (y5)
#

plt.subplot(3, 2, 3)
plt.stem(n_5, y5, linefmt='r-', markerfmt='ro', basefmt='k-')
plt.title('Sinal de Saída y5[n] (mode=\'full\')')
plt.xlabel('Amostras (n)')
plt.ylabel('Amplitude')
plt.grid(True)
plt.xticks(n_5)

# 
# Plot do Sinal de Saída Convolved (y7)
#

plt.subplot(3, 2, 4)
plt.stem(n_7, y7, linefmt='r-', markerfmt='ro', basefmt='k-')
plt.title('Sinal de Saída y7[n] (mode=\'full\')')
plt.xlabel('Amostras (n)')
plt.ylabel('Amplitude')
plt.grid(True)
plt.xticks(n_7)

# 
# Plot do Sinal de Saída Convolved (y9)
#

plt.subplot(3, 2, 5)
plt.stem(n_9, y9, linefmt='r-', markerfmt='ro', basefmt='k-')
plt.title('Sinal de Saída y9[n] (mode=\'full\')')
plt.xlabel('Amostras (n)')
plt.ylabel('Amplitude')
plt.grid(True)
plt.xticks(n_9)

# 
# Plot do Sinal de Saída Convolved (yg)
#

plt.subplot(3, 2, 6)
plt.stem(n_g, yg, linefmt='r-', markerfmt='ro', basefmt='k-')
plt.title('Sinal de Saída yg[n] (mode=\'full\')')
plt.xlabel('Amostras (n)')
plt.ylabel('Amplitude')
plt.grid(True)
plt.xticks(n_g)

plt.tight_layout()
plt.show()

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: