I have a given signal ds and I want to compute its scaled FFT. By that I mean that I want to get the FFT but I want the frequencies axis to be in the range of [-1,1]. My question is how could I do that?
Here is my code:
contour_fft = np.fft.fft(ds)
contour_fft = np.fft.fftshift(contour_fft)
magnitude = abs(contour_fft)
sample_rate = 1.0
N = len(ds)
freq = np.fft.fftfreq(N, sample_rate)
freq = np.fft.fftshift(freq)
# Plot the magnitude
plt.figure(figsize=(50, 5))
plt.plot(freq, magnitude)
plt.axhline(0, color='black', linestyle='--', linewidth=1, label='Zero Magnitude')
plt.xlabel('Frequency')
plt.ylabel('Contour FFT Magnitude')
plt.legend()
plt.title('Contour FFT Magnitude Plot')
plt.grid(True)
plt.show()
I tried to change the sample rate of freq=np.fft.fftfreq(N, sample_rate), and it did scaled the fft different, but I did not know how to change it to be in the range of [-1,1].
You can generate
Nrandom numbers in this range,fftfreqcan get a scalar in thedparameter