FourierSeries:

-------------------------------------------------------------------------------
   Generates the Fourier Series sine and cosine coefficients of a signal using
	the matlab function FFT.  Returns the coefficients for a user specified 
	number of harmonics with the largest magnitudes.
-------------------------------------------------------------------------------
   Form:
   [x, w, h] = FourierSeries( y, t, n )
-------------------------------------------------------------------------------

   ------
   Inputs
   ------
   y             (k,:)    The signal whose coefficients are to be found.  if y
						   is a matrix each row contains a separate signal. k is 
						   number of signals to be analyzed

   t             (1,:)    Time

   n             (1,:)    Number of harmonic terms to return

   -------
   Outputs
   -------
   x          (2h+1,k)    [constant;sine terms;cosine terms]

	w			  (k,n)    Frequncies of harmonics	

   h					   The number of sine/cosine terms returned.  The length
						   of x will thus be 2*h+1


  	NOTE
 	----
	The harmonics are found by finding the peaks in the magnitude, m, of the 
	transform. Using the function FindPeaks.  
					m = sqrt(a.^2 + b.^2)
					a   cosine coefficients
					b   sine coefficients

	note: if the signal is very rough, peaks which are not true harmonics will be
         found.  The effects of this should be minimized since the peaks are sorted
		  by magnitude.
  
	The number of sine/cosine terms returned varies according to the following:
		-  when n is not specified, 
		  			 h = N/2 		where N is the length of the signal

		-  when n < number of harmonics found
					 h = n
		-  when N/2 > n > number of harmonics found
					 h = number of harmonics found

       -  when multiple signals are being analyzed, the number of harmonics is
		   determined by the signal with the most peaks and the others signals
		   will simply return zeroes as place holders.

          FOR EXAMPLE:  
		   if y contains two signals of length 100, where signal1 is found to
		   have 4 harmonics and signal2 is found to have 8 harmonics  h will be 
		   as follows.
			 n <= 4, h = n
		 4 < n <= 8, h = n  but in case of signal1 places > 4 will be zero
        8 < n < 50, h = 8  but in case of signal1 places > 4 will be zero
			 n >=50, h = 50 full set of coefficients is returned	
-------------------------------------------------------------------------------

Children:

Common: Control/FindPeaks
Common: Graphics/Plot2D
Common: Math/Odd