update with FFT duration code

This commit is contained in:
Dorian VELOSO 2024-03-12 10:25:28 +01:00
parent 2b37fae0a1
commit 165f7c6d98
1 changed files with 28 additions and 0 deletions

28
computeFFTDuration.m Normal file
View File

@ -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;