clear;
x=[0:0.1:8] * pi;  % range from 0 to 8pi with last entry actually 8pi

y = 0*x;           % total starts at 0 for each value of x
                   % creates a vector with the same number of values as in x,
                   % but each value is 0

% Compute the fournier series for each value of x
for n = 1:1000
    y = y + sin(n*x)/n;  % do not need element-wise operators here
end                      % because n is a scalar (inside the loop)

plot(x,y);
axis([x(1) x(length(x)),  -pi/2, pi/2])
title('first method')