0

I have an array named fft with the length of length (800) and want to get the np.argmax(fft) and get as expected the maximum at position result (420). The data of the fft is from -pi/2 to pi/2 (-90° to 90°). So the position of the maximum is actually at 0.078° radian. There is also an array x_axis = np.linespace(-np.pi/2, np.pi/2, length).

I thought maybe there is a way to use the np.argmax() and the x_axis in one function or two to get the angle directly. Would make the code clearer then using result = np.argmax(fff) / length * np.pi - np.pi/2.

Thanks

Dominik
  • 35
  • 5
  • 1
    you can put indexes after linspace. eg: `np.linspace(-np.pi/2, np.pi/2, length)[0]` is the first element, so you can do `result = x_axis[np.argmax(fft)]` –  May 13 '22 at 09:43
  • @SembeiNorimaki thanks this worked. I also didn't needed to change anything in the linspace. ```np.linspace(-np.pi/2, np.pi/2, length)```works fine. Thanks – Dominik May 13 '22 at 09:58

0 Answers0