function [freq, power] = get_spectrum(amplitude, f_sampling) % function [freq, power] = get_spectrum(amplitude, f_sampling) % % Generates the normalized power spectrum % Input to the function are the waveform samples and sampling frequency. % Outputs are normalized power (in dB units) and Frequency (in Hz). % % Courtsey Chris Ranson % a=length(amplitude); temp = fft(amplitude,a); Y=fftshift(temp); Pyy = Y.*conj(Y)/a; %power = Pyy; power=(Pyy./max(Pyy)); %Normalize Spectrum power=10.*log10(power); freq = (-(a/2 - 1):((a/2))) * ((f_sampling)/a);