% Fourier Coefficients and Partial Fourier Series Sums Demonstration
%
% FOURCOEF calculates the Fourier Sine and Cosine coefficients 
% for a given periodic function, and plots the Nth partial sum 
% approximating the function.  Edit the value of N in its box to 
% change the order of the partial Fourier series.  Note that in  
% most cases only the alternate harmonics are non-zero.  The first 
% three functions are Odd Square (Example 2.3), Even Triangle, and  
% Odd Linked Parabolas.  In this sequence each function is the integral 
% of the previous one.  The square wave has a discontinuity in value, 
% the triangle wave is continuous with a jump in the first derivative, 
% and the linked parabolas are continuous with a jump in the second 
% derivative.  The rectified sine wave is of amplitude 169 V and 
% frequency 60 Hz, the output of rectified U.S. standard A.C. electricity.
% In the default operation of FOURCOEF, the Line Segments function is 
% made up of line segments linking the points
% x=[-1 1 exp(1) exp(1) pi exp(2)], and 
% y=2*rand(1,6)-1.
% For any case, pushing the "Return" button returns the N Fourier  
% coefficients to the root workspace variables A0, An, and Bn.
%
% FOURCOEF(X,Y) replaces the default line segments in the Line Segments 
% function with the line segments defined by X and Y, and starts 
% the display in the Line Segments mode.  X must be increasing, but
% repeated values are allowed (to define jumps).
% For example, fourcoef([0 0.3 0.3 1],[1 1 0 0]) will analyze a square 
% wave of 30% duty cycle.
% 
% See also FUNSPECT, DATASPECT, FIRSTORD, SECONDORD, 
% MULTISYS, and SAMPLING.
%
