Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
function [ P1, f ] = ssfft( X, Fs )
%ssfft Computes the single-sided amplitude spectrum of a signal.
% [ P1, f ] = ssfft( X, Fs )
% X Input signal.
% Fs Sampling frequency.
% P1 Single-sided Amplitude Spectrum.
% f Frequency range.
% Plot with e.g. stem(f, P1), plot(f, P1).
L = length(X);
Y = fft(X);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.