% Example 6.14
N = input('Input N: ');
T = input('Input T: ');
%
% compute the approximate of X(w)
t=0:T:2;
x = [t-1 zeros(1,N-length(t))];    
[Xapp,w] = contfft(x,T);  % uses the m-file contfft
gam = 2*pi/N/T;
k = 0:10/gam;    % for plotting purposes
%
%  compute the actual X(w)
w = 0.05:.05:10;
Xact = j*2*(w.*cos(w)-sin(w))./(w.*w);
plot(k*gam,abs(Xapp(1:length(k))),'o',w,abs(Xact))
title(['Example 6.14, N = ',num2str(N),', T = ',num2str(T)])
ylabel('|X|')
xlabel('Frequency (rad/sec)')
text(4.5,.8,'------- Actual X')
text(4.5,.7,'o o o Approximate X')

