-1

I'm newly learning and practicing python. My question is, how can find the period of the signal through the python? And in which different ways?

"A periodic signal (but only ploted on a bounded interval)"

signal1=np.exp(np.sin(20*np.pi*t)*np.sin(30*np.pi*t))
fig, ax=plt.subplots()
ax.plot(t,signal1);```

amy
  • 23
  • 8
  • Please repeat the intro tour, especially [how to ask](https://stackoverflow.com/help/how-to-ask). This is far too broad for Stack Overflow. There are Fourier Transform functions you can find with a simple browser search -- which we expect before you post here. – Prune Apr 02 '20 at 18:16

2 Answers2

1

Well, I guess that is not a really easy question as it may seem because not all functions are periodic, you can use np.fft.fft like this:

plt.plot(np.abs(np.fft.fft(signal1)))

enter image description here

This is the graph of the frequencies of this particular signal.

Community
  • 1
  • 1
Bruno Mello
  • 4,448
  • 1
  • 9
  • 39
0

A Fourier Transform outputs the frequencies of the sinusoidal components of a signal. Unless the signal is pure, i.e., consists of only one sinusoidal, you are not guaranteed to get the periods from an fft.

For example: let f(t) = sin(2pit/4) + sin(2pit/6), a sum of two sine waves with periods 4 and 6. In that case, the period of f(t) is the Least Common Multiple of the two periods, namely 12.

Hence, you are indeed looking for autocorrelation.

artmyb
  • 1
  • 1