MidtermSignal/computeFFTDuration.m

28 lines
611 B
Matlab

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;