% plotspect(x,t) plots the spectrum of the signal x
% whose values are sampled uniformly at time (in seconds) specified in t

function plotspect(x,t)
N=length(x);                                    % length of the signal x
Ts = t(2)-t(1);                                 % find sampling interval
ssf=((-N/2):(N/2-1))/(Ts*N);                    % frequency vector
fx=Ts*fft(x(1:N));                              % do DFT/FFT
fxs=fftshift(fx);                               % shift it for plotting
subplot(2,1,1);
set(plot(t,x),'LineWidth',1.5);                 % plot the waveform
%set(plot(t,real(x)),'LineWidth',1.5);       
%hold on
%set(plot(t,imag(x),'m--'),'LineWidth',1.5); 
%hold off
%legend('Re','Im')
xlabel('Seconds');                              % label the axes
subplot(2,1,2);          
set(plot(ssf,abs(fxs)),'LineWidth',1.5);        % plot magnitude spectrum
xlabel('Frequency [Hz]'); ylabel('Magnitude')   % label the axes

