@signalprocessing/transforms v2.0.11
Install
npm install @signalprocessing/transforms
Usage
This module can be both imported as commonJS or ES module.
Fast Fourier Transform ( fft )
Inverse Fast Fourier Transform ( ifft )
This functions implement fast Fourier transform and inverse fast Fourier transform of any given real or complex signal.
FFT of real signal:
let [realFFTCoeffcients, imaginaryFFTCoeffcients] = fft(realSignal)
.
FFT of complex signal:
let [realFFTCoeffcients, imaginaryFFTCoeffcients] = fft(realPartofSignal, imaginaryPartofSignal)
.
IFFT of any signal:
let [realPartofSignal, imaginaryPartofSignal] = ifft(realFFTCoeffcients, imaginaryFFTCoeffcients)
.
Note: If imaginaryFFTCoeffcients is not present for the ifft function, then you must artifically create imaginaryFFTCoeffcients array of all zeros with the same size of realFFTCoeffcients array.
If you have the signal A
, then you should get ifff(fft(A)) == A
with some numerical difference.
//Example
//import fft
let fft=require("@signalprocessing/transforms").fft
//import ifft
let ifft=require("@signalprocessing/transforms").ifft
//Sampling rate
let Fs = 1000;
//Sampling period
let T = 1 / Fs;
//Length of signal
let L = 1500;
//Time data
let t = Array.from({ length: L }, (x, i) => i * T);
//A real signal containing a 30 Hz sinusoid of amplitude 0.5 and a 100 Hz sinusoid of amplitude 1.
let realSignal = Array.from(t, (x, i) => 0.5 * Math.sin(2 * Math.PI * 30 * x) + Math.sin(2 * Math.PI * 100 * x));
//Compute the fast Fourier transform of the signal.
let [realFFTCoeffcients, imaginaryFFTCoeffcients] = fft(realSignal);
//Compute the inverse fast Fourier transform of the signal.
let [nRealSignal,nImagSignal] = ifft(realFFTCoeffcients,imaginaryFFTCoeffcients)
License
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago