From 165f7c6d987034ae352d05b1e8ea1e06492d54c3 Mon Sep 17 00:00:00 2001 From: Dorian VELOSO Date: Tue, 12 Mar 2024 10:25:28 +0100 Subject: [PATCH] update with FFT duration code --- computeFFTDuration.m | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 computeFFTDuration.m diff --git a/computeFFTDuration.m b/computeFFTDuration.m new file mode 100644 index 0000000..2e957b2 --- /dev/null +++ b/computeFFTDuration.m @@ -0,0 +1,28 @@ +function duration = computeFFTDuration(x, fs, pad) +%%%%%%%%%%%%%%%%%% +%function duration = computeFFTDuration(x, fs, pad) +% +% Task: Determine the duration of a DFT/FFT +% +% Input: +% - signal: the input signal to process +% - fs: the sampling rate +% - pad: boolean if true, signal is padded to the next power of 2 otherwise the dft is computed on the signal length +% +% Output: +% - duration: duration of the computation process for the DFT/FFT +% +% +% Guillaume Gibert, guillaume.gibert@ecam.fr +% 27/04/2022 +%%%%%%%%%%%%%%%%%% + +n = length(x); + +if (pad) + n = 2^nextpow2(n); +end + +tic + y = fft(x, n); +duration = toc; \ No newline at end of file