%% Example 6.1

%% Initialization
close all
clear N X Y j YY Z x

N = 16;
X = [0 : 2*pi/16 : 30*pi/16];
Y = zeros(length(X),1);

%% Define the function (step down)
for j = [1:length(X)]
    if X(j)<(pi-0.001)
        Y(j) = 1;
    else Y(j) = -1;
    end;
end;

%% Coefficients of the FT
YY = fft(Y)/N;
Z = YY(1:N/2 + 1,1)


%% Generate the plot

x = [-8:1:8];
Z = [flipud(Z(2:end,1));Z];

plot(x,abs(Z),'k.')

