Concept Flow - FFT computation (fft)
Input: Time-domain signal
Apply FFT algorithm
Compute frequency components
Output: Frequency-domain data
The FFT takes a time signal, processes it, and outputs its frequency components.
import numpy as np from scipy.fft import fft x = np.array([1, 2, 3, 4]) X = fft(x) print(X)
| Step | Action | Input/Variable | Result/Output |
|---|---|---|---|
| 1 | Define input array x | [1, 2, 3, 4] | x = [1 2 3 4] |
| 2 | Call fft(x) | x = [1 2 3 4] | Compute FFT using Cooley-Tukey algorithm |
| 3 | Calculate frequency components | x | [10.+0.j -2.+2.j -2.+0.j -2.-2.j] |
| 4 | Print FFT result | FFT output | [10.+0.j -2.+2.j -2.+0.j -2.-2.j] |
| Variable | Start | After fft call | Final |
|---|---|---|---|
| x | [1 2 3 4] | [1 2 3 4] | [1 2 3 4] |
| X | undefined | computed | [10.+0.j -2.+2.j -2.+0.j -2.-2.j] |
FFT computation (fft): - Input: time-domain signal array - Use scipy.fft.fft(x) to compute - Output: complex frequency components - First output is sum (DC component) - Complex values show amplitude and phase