Skip to content

Instantly share code, notes, and snippets.

@ha7ilm
Created October 31, 2022 06:06
Show Gist options
  • Save ha7ilm/05c333b3ca86b6dc3b82be28fdf97306 to your computer and use it in GitHub Desktop.
Save ha7ilm/05c333b3ca86b6dc3b82be28fdf97306 to your computer and use it in GitHub Desktop.
calculate the derivative of a signal with torch.fft
F_signal = torch.fft.rfft(signal])
w = ((((torch.arange(0,301))/600)*(2*torch.pi))) #signal is 600 samples long
d_signal = torch.fft.irfft(w*torch.tensor(complex(0,1))*F_signal)*(1/dt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment