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