Created
September 29, 2023 15:17
-
-
Save numeroSette/9022768bfddc562fb6e9d1372c312332 to your computer and use it in GitHub Desktop.
Transformada de Fourier
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
# Frequência do sinal | |
frequencia_sinal = 5 # Hz | |
# Frequência de amostragem | |
frequencia_amostragem = 100 # Hz | |
# Tempo de amostragem | |
t = np.linspace(0, 1, frequencia_amostragem, endpoint=False) # 1 segundo | |
# Criar um sinal senoidal | |
sinal = np.sin(2 * np.pi * frequencia_sinal * t) | |
# Calcular a Transformada Rápida de Fourier | |
fourier_transformado = np.fft.fft(sinal) | |
# Frequências correspondentes | |
frequencias = np.fft.fftfreq(len(fourier_transformado)) * frequencia_amostragem | |
# Plotar o sinal original e sua transformada de Fourier | |
plt.figure(figsize=(12, 6)) | |
plt.subplot(2, 1, 1) | |
plt.plot(t, sinal) | |
plt.title('Sinal Original') | |
plt.subplot(2, 1, 2) | |
plt.plot(frequencias, np.abs(fourier_transformado)) | |
plt.title('Magnitude da Transformada de Fourier') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment