function [f, m, p] = fft_plus (x, Fs)
%
% from https://www.mathworks.com/help/signal/examples/practical-introduction-to-frequency-domain-analysis.html
% function [f, m, p] = fft_plus (x, Fs)
% inputs: x = signal, Fs = sampling rate (Hz)
% outputs: f = frequency, m = magnitude, p = phase

L = length(x);

Y = fft(x,L);

f = ((0:1/L:1-1/L)*Fs).';

m = abs(Y);        % Magnitude of the FFT
p = unwrap(angle(Y));  % Phase of the FFT

f = f(1:floor(L/2));
m = m(1:floor(L/2));
p = p(1:floor(L/2));

end
