# TFSD - Transformada de Fourier de um sinal discreto

Neste notebook vamos investigar as diferenças entre a Transformada de Fourier (TF) e a Transformada de Fourier de um Sinal Discreto (TFSD). Consideremos o exemplo do pulso retangular.


```python
# importar as bibliotecas necessárias
import numpy as np # arrays
import matplotlib.pyplot as plt # plots
plt.rcParams.update({'font.size': 14})
```

# TF de um pulso retangular

Sabemos que a TF de um pulso retangular é a função sinc, dada por:

\begin{equation}
X(\mathrm{j} \omega) = \frac{2 \mathrm{sin}(\omega T_1)}{\omega}
\tag{1}
\end{equation}


```python
# time signal
fs = 1000
time = np.arange(-7, 7+1/fs, 1/fs)
xt = np.ones(len(time))
T1 = 3
xt[time<-T1] = np.zeros(len(time[time<-T1]))
xt[time>T1] = np.zeros(len(time[time>T1]))

# Fourier transform
w = np.linspace(-20, 20, 1000)
Xw = 2*np.sin(w*T1)/w

# Figure
plt.figure()
plt.title(r'Pulso retangular - $x(t)$')
plt.plot(time, xt, '-b', linewidth = 2)
plt.grid(linestyle = '--', which='both')
plt.xlabel('Tempo [s]')
plt.ylabel('Amplitude [-]')
plt.xlim((time[0], time[-1]))
plt.tight_layout()
plt.show()

plt.figure()
plt.title(r'Pulso retangular - $X(j \omega)$')
plt.plot(w/(2*np.pi), np.abs(Xw), '-b', linewidth = 2)
plt.grid(linestyle = '--', which='both')
plt.xlabel('Frequência [Hz]')
plt.ylabel('Amplitude [-]')
plt.xlim((w[0]/(2*np.pi), w[-1]/(2*np.pi)))
plt.tight_layout()
plt.show()
```

# TFSD de um pulso retangular

Consideremos agora a TFSD do pulso retangular. Neste caso, a TFSD é dada por

\begin{equation}
X(\mathrm{e}^{\mathrm{j} \omega})=\sum\limits^{\infty}_{n=-\infty}x[n]e^{-\mathrm{j}\omega t}
\tag{2}
\end{equation}

o que, para o pulso retangular discreto resulta em:

\begin{equation}
X(\mathrm{e}^{\mathrm{j} \omega})= \frac{\mathrm{sin}(\omega(N_1+1/2))}{\mathrm{sin}(\omega/2)}
\end{equation}

1. O espectro do sinal discreto continua sendo contínuo
2. No entanto, é periódico


```python
# discrete time signal
n = np.arange(-7, 7)
xn = np.ones(len(n))
N1 = 3
xn[n<-N1] = np.zeros(len(n[n<-T1]))
xn[n>N1] = np.zeros(len(n[n>T1]))

# Fourier transform
w = np.linspace(-20, 20, 1000)
Xejw = 2*np.sin(w*(N1+1/2))/np.sin(w/2)

# Figure
plt.figure()
plt.title(r'Pulso retangular - $x[n]$')
plt.stem(n, xn, '-b', basefmt=" ", use_line_collection=  True)
plt.grid(linestyle = '--', which='both')
plt.xlabel('Tempo [s]')
plt.ylabel('Amplitude [-]')
plt.xlim((time[0], time[-1]))
plt.tight_layout()
plt.show()

plt.figure()
plt.title(r'Pulso retangular - $X(e^{j \omega})$')
plt.plot(w/(2*np.pi), np.abs(Xejw), '-b', linewidth = 2)
plt.grid(linestyle = '--', which='both')
plt.xlabel('Frequência [Hz]')
plt.ylabel('Amplitude [-]')
plt.xlim((w[0]/(2*np.pi), w[-1]/(2*np.pi)))
plt.tight_layout()
plt.show()
```

5da2461e017ee9a02c46bed24b53ad1ffde6c1f6
ipynb
Jupyter Notebook
Aula 41 - TF de um sinal discreto/TFSD.ipynb
RicardoGMSilveira/codes_proc_de_sinais
e6a44d6322f95be3ac288c6f1bc4f7cfeb481ac0
CC0-1.0
2020-10-01T20:59:33.000Z
2021-07-27T22:46:58.000Z
Aula 41 - TF de um sinal discreto/TFSD.ipynb
RicardoGMSilveira/codes_proc_de_sinais
e6a44d6322f95be3ac288c6f1bc4f7cfeb481ac0
CC0-1.0
Aula 41 - TF de um sinal discreto/TFSD.ipynb
RicardoGMSilveira/codes_proc_de_sinais
e6a44d6322f95be3ac288c6f1bc4f7cfeb481ac0
CC0-1.0
2020-10-15T12:08:22.000Z
2021-04-12T12:26:53.000Z
Qwen/Qwen-72B
1. YES
2. YES