Analiza coerenței a două semnale: Diferență între versiuni
Sari la navigare
Sari la căutare
Pagină nouă: <source lang="Python"> import numpy as np import matplotlib.pyplot as plt # https://matplotlib.org/gallery/index.html # Fixing random state for reproductibility np.random.seed(196... |
Fără descriere a modificării |
||
| Linia 4: | Linia 4: | ||
# https://matplotlib.org/gallery/index.html | # https://matplotlib.org/gallery/index.html | ||
# | # Fixarea stării aleatorii (pentru reproductibilitate) | ||
np.random.seed(19680801) | np.random.seed(19680801) | ||
| Linia 12: | Linia 12: | ||
nse2 = np.random.randn(len(t)) # white noise 2 | nse2 = np.random.randn(len(t)) # white noise 2 | ||
# | # Două semnale cu o componentă coerentă de 10Hz și o componentă aleatorie | ||
s1 = np.sin(2 * np.pi * 10 * t) + nse1 | s1 = np.sin(2 * np.pi * 10 * t) + nse1 | ||
s2 = np.sin(2 * np.pi * 10 * t) + nse2 | s2 = np.sin(2 * np.pi * 10 * t) + nse2 | ||
| Linia 20: | Linia 20: | ||
axs[0].plot(t, s1, t, s2) | axs[0].plot(t, s1, t, s2) | ||
axs[0].set_xlim(0, 2) | axs[0].set_xlim(0, 2) | ||
axs[0].set_xlabel(' | axs[0].set_xlabel('timp') | ||
axs[0].set_ylabel('s1 | axs[0].set_ylabel('s1 și s2') | ||
axs[0].grid(True) | axs[0].grid(True) | ||
cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) | cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) | ||
axs[1].set_ylabel(' | axs[1].set_ylabel('coerența') | ||
fig.tight_layout() | fig.tight_layout() | ||
plt.show() | plt.show() | ||
</source> | </source> | ||
Versiunea de la data 17 ianuarie 2020 22:30
import numpy as np
import matplotlib.pyplot as plt
# https://matplotlib.org/gallery/index.html
# Fixarea stării aleatorii (pentru reproductibilitate)
np.random.seed(19680801)
dt = 0.01
t = np.arange(0, 30, dt)
nse1 = np.random.randn(len(t)) # white noise 1
nse2 = np.random.randn(len(t)) # white noise 2
# Două semnale cu o componentă coerentă de 10Hz și o componentă aleatorie
s1 = np.sin(2 * np.pi * 10 * t) + nse1
s2 = np.sin(2 * np.pi * 10 * t) + nse2
axs: object
fig, axs = plt.subplots(2, 1)
axs[0].plot(t, s1, t, s2)
axs[0].set_xlim(0, 2)
axs[0].set_xlabel('timp')
axs[0].set_ylabel('s1 și s2')
axs[0].grid(True)
cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt)
axs[1].set_ylabel('coerența')
fig.tight_layout()
plt.show()