# Potência, Energia, Valor médio e RMS

Neste notebook avaliamos a potência, energia, valor médio e RMS de um sinal definidos de acordo com as seguintes equações:

\begin{equation}
P=\frac{1}{t_{2}-t_{1}}\int^{t_{2}}_{t_{1}}|x(t)|^2\mathrm{d}t
\end{equation}

\begin{equation}
E=\int^{t_{2}}_{t_{1}}|x(t)|^2\mathrm{d}t
\end{equation}

\begin{equation}
x_0=\frac{1}{t_{2}-t_{1}}\int^{t_{2}}_{t_{1}}x(t)\mathrm{d}t
\end{equation}

\begin{equation}
x_{\text{RMS}}=\sqrt{\frac{1}{t_{2}-t_{1}}\int^{t_{2}}_{t_{1}}x^2(t)\mathrm{d}t}
\end{equation}


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


```python
# tempo e frequência
Tp = 1
freq = 1
t = np.linspace(0, Tp, 1000) # vetor temporal

# sinal senoidal
A = 1
xt = A*np.sin(2*np.pi*freq*t)

# Valor médio
x_0 = np.mean(xt)

# Valor RMS
x_RMS = np.sqrt(np.mean(xt**2))



plt.figure(figsize=(12,4))
plt.title('Sinal, Valor médio e RMS')
plt.plot(t, xt, '--b', linewidth = 1, label = r'$x(t)$ [-]')
plt.plot(t, x_0*np.ones(len(t)), '--k', linewidth = 3, label = r'$x_0$ [-]')
plt.plot(t, x_RMS*np.ones(len(t)), '--r', linewidth = 3, label = r'$x_{RMS}$ [-]')
plt.legend(loc = 'upper right')
plt.grid(linestyle = '--', which='both')
plt.ylim((-1.2*A, 1.2*A))
plt.xlim((t[0], t[-1]))
plt.xlabel('Tempo [s]')
plt.ylabel('Amplitude [-]')

print('O valor médio é {:.4}'.format(x_0))
print('O valor RMS é {:.4}'.format(x_RMS))
```


```python

```

a6296ead1f1e3bd4e5b84b9beac6fc11ad15879b
ipynb
Jupyter Notebook
Aula 9 - Potencia e energia dos sinais/.ipynb_checkpoints/potencia e energia dos sinais-checkpoint.ipynb
RicardoGMSilveira/codes_proc_de_sinais
e6a44d6322f95be3ac288c6f1bc4f7cfeb481ac0
CC0-1.0
2020-10-01T20:59:33.000Z
2021-07-27T22:46:58.000Z
Aula 9 - Potencia e energia dos sinais/.ipynb_checkpoints/potencia e energia dos sinais-checkpoint.ipynb
RicardoGMSilveira/codes_proc_de_sinais
e6a44d6322f95be3ac288c6f1bc4f7cfeb481ac0
CC0-1.0
Aula 9 - Potencia e energia dos sinais/.ipynb_checkpoints/potencia e energia dos sinais-checkpoint.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