function dtftplot(x,N,Fs)
%DTFTPLOT Plots the spectrum of discrete time signals. 
%   DTFTPLOT(X,N,Fs) plots the spectral magnitude of the discrete 
%   time Fourier transform (DTFT) of signal X. Fs denotes the
%   sampling frequency. The DTFT is evaluated at 2N+1 frequencies
%   between -Fs/2 and +Fs/2. The DTFT is linearly interpolated in
%   between two adjacent frequency points.

%   Copyright (c) 1998 by Robert M. Nickel
%   $Revision: 1.0 $
%   $Date: 30-Mar-1998 $

% find scaling factor
F=1; FS='[Hz]';
if Fs>1e6; Fs=Fs*1e-6; F=1e6; FS='[MHz]'; end
if Fs>1e3; Fs=Fs*1e-3; F=1e3; FS='[kHz]'; end

% compute DTFT
[X,w]=dtft(x,N); X=abs(X);

% plot results
plot(0.5*Fs*w/pi,X);
axis([ -Fs/2 +Fs/2 0 1.1*max(X) ]);
ylabel('|X(f)|');
title('Spectral Magnitude of Signal x(n)');
xlabel(['f ',FS]);

