-1

I am a new user of Python. I have a signal that contains 16 datas.

for example: 'a = [ 1, 2, 3, 4, 1, 1, 1, 1, 1, 1 ,2, 3, 4, 1, 1]'

I tried to numpy.fft.fft but I can not figure out how can I sum these frequencies and calculate the Fourier Coefficients.

Thank you.

  • Have a look at [this](https://stackoverflow.com/questions/42842152/finding-fft-coefficients-from-fft-or-rfft-in-python), it would be an answer to your question. – Ruggero Oct 14 '21 at 13:08
  • Welcome to StackOverflow. This is not a free coding service. Provide a [**minimal reproducible example**](https://stackoverflow.com/help/minimal-reproducible-example). "Implement this feature for me" is off-topic for this site. You have to _make an honest attempt_, and then ask a _specific question_ about your algorithm or technique. Please take the [tour](https://stackoverflow.com/tour), read [what's on-topic here](https://stackoverflow.com/help/on-topic), [How to Ask](https://stackoverflow.com/questions/how-to-ask), and the [question checklist](https://meta.stackoverflow.com/q/260648). – aneroid Oct 14 '21 at 13:32

1 Answers1

0

The numpy docs include a helpful example at the end of the page for np.fft.fft (https://numpy.org/doc/stable/reference/generated/numpy.fft.fft.html)

Basically, you want to use np.fft.fft(a) to transform your data, in tandem with np.fft.fftfreq(np.shape(a)[-1]) to figure out which frequencies your transform corresponds to.

Check out the docs for np.fft.fftfreq as well (https://numpy.org/doc/stable/reference/generated/numpy.fft.fftfreq.html#numpy.fft.fftfreq)

See here (https://dsp.stackexchange.com/questions/26927/what-is-a-frequency-bin) for a discussion on frequency bins and here (https://realpython.com/python-scipy-fft/) for a solid tutorial on scipy/numpy fft.

jrudo
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 14 '21 at 13:38
  • Thank you so much sir, i have been trying to solve how can I find the Fourier Coefficients of these Signal ? – Emin Bülbül Oct 14 '21 at 14:49
  • See https://stackoverflow.com/questions/7195462/fft-coefficients-question The Fourier coefficients are the returned values. Each value is a coefficient for the sinusoid at the corresponding frequency obtained with fftfreq – jrudo Oct 14 '21 at 15:18