extracting phase information using numpy fft

后端 未结 2 828
野性不改
野性不改 2021-02-14 09:10

I am trying to use a fast fourier transform to extract the phase shift of a single sinusoidal function. I know that on paper, If we denote the transform of our function as T, th

2条回答
  •  说谎
    说谎 (楼主)
    2021-02-14 10:07

    Your points are not distributed equally over the interval, you have the point at the end doubled: 0 is the same point as 1. This gets less important the more points you take, obviusly, but still gives some error. You can avoid it totally, the linspace has a flag for this. Also it has a flag to return you the dt directly along with the array.

    Do

    t, dt = np.linspace(0, 1, num_t, endpoint=False, retstep=True)
    

    instead of

    t = np.linspace(0,1,num_t)
    dt = 1.0/num_t
    

    then it works :)

提交回复
热议问题