2020-11-03 22:21:19 +00:00
|
|
|
function [frequencies, values] = fft_(signal, sample_frequency)
|
|
|
|
|
|
|
|
L=length(signal);
|
|
|
|
|
|
|
|
Y = fft(signal);
|
|
|
|
P2 = abs(Y); % two-sided spectrum
|
|
|
|
% P2 = abs(Y/L); % two-sided spectrum
|
2020-11-04 19:22:05 +00:00
|
|
|
P1 = P2(1:floor(L/2+1)); % single-sided spectrum
|
2020-11-03 22:21:19 +00:00
|
|
|
P1(2:end-1) = 2*P1(2:end-1);
|
|
|
|
frequencies = sample_frequency*(0:(L/2))/L;
|
|
|
|
values = P1;
|
|
|
|
|
|
|
|
end
|
|
|
|
|