% plotspec_v3(x,Ts) plots the spectrum of the signal x
% Ts = time (in seconds) between adjacent samples in x
% Modified by JVK to make the spectrum amplitude correspond
% to that of the CT Fourier Transform and to properly plot when
% signal length is odd

function plotspec_v3(x,Ts)

N=length(x);                                % length of the signal x
n = 1:N;
ssf=(n - 1 - floor(N/2))/(Ts*N);            % frequency vector
X=Ts*fftshift(fft(x));                      % do DFT/FFT
X_dB = 20*log10(abs(X));
plot(ssf,X_dB)                              % plot magnitude spectrum
xlabel('frequency'); ylabel('magnitude in dB')   % label the axes
