In [1]:
import matplotlib
matplotlib.use('nbagg')
In [3]:
import numpy as np
import matplotlib.pyplot as plt

M = np.loadtxt('2masses_libre.txt')
t = M[:,0]
x_a = M[:,1]
x_b = M[:,2]

plt.figure()
plt.plot(t, x_a, 'r-', label='1')
plt.plot(t, x_b, 'b-', label='2')
plt.xlabel(r'$t$ [s]')
plt.ylabel('Position')
plt.legend()
plt.show()

Transformée de Fourier

In [5]:
n = x_a.size
f = np.fft.fftfreq(x_a.size, t[1]-t[0])
F_a = np.fft.fft(x_a-np.mean(x_a))  # attention: nombre complexe
F_b = np.fft.fft(x_b-np.mean(x_b))

plt.figure()
plt.plot(f, np.abs(F_a), 'r-')
plt.plot(f, np.abs(F_b), 'b-')
plt.xlabel(r'$f$ [Hz]')
plt.ylabel('FFT')
plt.show()