<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5 plus MathML//EN" "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_mathml.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="m10625">
  <name>Spectrum Analyzer: MATLAB Exercise</name>
  <metadata>
  <md:version>2.8</md:version>
  <md:created>2002/06/03</md:created>
  <md:revised>2003/08/01 11:25:58.722 GMT-5</md:revised>
  <md:authorlist>
    <md:author id="appadwed">
      <md:firstname>Swaroop</md:firstname>
      
      <md:surname>Appadwedula</md:surname>
      <md:email>appadwed@uiuc.edu</md:email>
    </md:author>
    <md:author id="dljones">
      <md:firstname>Douglas</md:firstname>
      <md:othername>L.</md:othername>
      <md:surname>Jones</md:surname>
      <md:email>dl-jones@uiuc.edu</md:email>
    </md:author>
    <md:author id="kramer">
      <md:firstname>Michael</md:firstname>
      <md:othername>L.</md:othername>
      <md:surname>Kramer</md:surname>
      <md:email>kramer@ifp.uiuc.edu</md:email>
    </md:author>
    <md:author id="moussa">
      <md:firstname>Dima</md:firstname>
      
      <md:surname>Moussa</md:surname>
      <md:email>dmoussa@uiuc.edu</md:email>
    </md:author>
    <md:author id="bwade">
      <md:firstname>Brian</md:firstname>
      
      <md:surname>Wade</md:surname>
      <md:email>bwade@uiuc.edu</md:email>
    </md:author>
    <md:author id="jake">
      <md:firstname>Jake</md:firstname>
      
      <md:surname>Janevitz</md:surname>
      <md:email>jake@janevitz.com</md:email>
    </md:author>
    <md:author id="dsachs">
      <md:firstname>Daniel</md:firstname>
      <md:othername>Grobe</md:othername>
      <md:surname>Sachs</md:surname>
      <md:email>sachs@uiuc.edu</md:email>
    </md:author>
    <md:author id="mjberry">
      <md:firstname>Matthew</md:firstname>
      <md:othername>J.</md:othername>
      <md:surname>Berry</md:surname>
      <md:email>mjberry@uiuc.edu</md:email>
    </md:author>
    <md:author id="markhaun">
      <md:firstname>Mark</md:firstname>
      <md:othername>A.</md:othername>
      <md:surname>Haun</md:surname>
      <md:email>markhaun@uiuc.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="appadwed">
      <md:firstname>Swaroop</md:firstname>
      
      <md:surname>Appadwedula</md:surname>
      <md:email>appadwed@uiuc.edu</md:email>
    </md:maintainer>
    <md:maintainer id="dljones">
      <md:firstname>Douglas</md:firstname>
      <md:othername>L.</md:othername>
      <md:surname>Jones</md:surname>
      <md:email>dl-jones@uiuc.edu</md:email>
    </md:maintainer>
    <md:maintainer id="dsachs">
      <md:firstname>Daniel</md:firstname>
      <md:othername>Grobe</md:othername>
      <md:surname>Sachs</md:surname>
      <md:email>sachs@uiuc.edu</md:email>
    </md:maintainer>
    <md:maintainer id="mjberry">
      <md:firstname>Matthew</md:firstname>
      <md:othername>J.</md:othername>
      <md:surname>Berry</md:surname>
      <md:email>mjberry@uiuc.edu</md:email>
    </md:maintainer>
    <md:maintainer id="butala">
      <md:firstname>Mark</md:firstname>
      <md:othername>D.</md:othername>
      <md:surname>Butala</md:surname>
      <md:email>butala@uiuc.edu</md:email>
    </md:maintainer>
    <md:maintainer id="rars">
      <md:firstname>Ricardo</md:firstname>
      <md:othername>Anthony</md:othername>
      <md:surname>Radaelli-Sanchez</md:surname>
      <md:email>ricky@alumni.rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="rlmorris">
      <md:firstname>Robert</md:firstname>
      <md:othername>L.</md:othername>
      <md:surname>Morrison</md:surname>
      <md:email>rlmorris@uiuc.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>Fourier transform</md:keyword>
    <md:keyword>Fast Fourier transform</md:keyword>
    <md:keyword>FFT</md:keyword>
    <md:keyword>Discrete Fourier Transform</md:keyword>
    <md:keyword>DFT</md:keyword>
    <md:keyword>Discrete Time Fourier Transform</md:keyword>
    <md:keyword>DTFT</md:keyword>
    <md:keyword>boxcar</md:keyword>
    <md:keyword>hamming</md:keyword>
    <md:keyword>mainlobe</md:keyword>
    <md:keyword>sidelobe</md:keyword>
    <md:keyword>twiddle-factor</md:keyword>
    <md:keyword>bit-reversed</md:keyword>
    <md:keyword>windowing</md:keyword>
    <md:keyword>zero-pad</md:keyword>
    <md:keyword>DSP</md:keyword>
  </md:keywordlist>

  <md:abstract>You will investigate the effects of windowing and zero-padding on the Discrete Fourier Transform of a signal.  </md:abstract>
</metadata>





  <content>
    <section id="sec2">
      <name>MATLAB Exercise</name>
      <para id="p6">
	Since the DFT is a sampled version of the spectrum of a
	digital signal, it has certain sampling effects.  To explore
	these sampling effects more thoroughly, we consider the effect
	of multiplying the time signal by different window functions
	and the effect of using zero-padding to increase the length
	(and thus the number of sample points) of the DFT.  Using the
	following MATLAB script as an example, plot the
	squared-magnitude response of the following test cases over
	the digital frequencies
	<m:math>
	  <m:apply>
	    <m:eq/>
	    <m:ci>
	      <m:msub>
		<m:mi>ω</m:mi>
		<m:mi>c</m:mi>
	      </m:msub>
	    </m:ci>
	    <m:interval>
	      <m:apply>
		<m:divide/>
		<m:pi/>
		<m:cn>8</m:cn>
	      </m:apply>
	      <m:apply>
		<m:divide/>
		<m:apply>
		  <m:times/>
		  <m:cn>3</m:cn>
		  <m:pi/>
		</m:apply>
		<m:cn>8</m:cn>
	      </m:apply>
	    </m:interval>
	  </m:apply>
	</m:math>.  
      </para>
      <list id="list1" type="enumerated">
	<item>rectangular window with no zero-padding</item>
	<item>hamming window with no zero-padding</item>
	<item>rectangular window with zero-padding by factor of four
	(<foreign>i.e.</foreign>, 1024-point FFT)</item>
	<item>hamming window window with zero-padding by factor of
	  four</item>
      </list>
      <para id="p7">
	Window sequences can be generated in MATLAB by using the
	<code>boxcar</code> and <code>hamming</code> functions.
      </para>
      <code type="block">
	<![CDATA[
	1  N = 256;                % length of test signals
	2  num_freqs = 100;        % number of frequencies to test
	3
	4  % Generate vector of frequencies to test
	5
	6  omega = pi/8 + [0:num_freqs-1]'/num_freqs*pi/4;
	7
	8  S = zeros(N,num_freqs);                 % matrix to hold FFT results
	9
	10
	11  for i=1:length(omega)                   % loop through freq. vector
	12     s = sin(omega(i)*[0:N-1]');          % generate test sine wave
	13     win = boxcar(N);                     % use rectangular window
	14     s = s.*win;                          % multiply input by window
	15     S(:,i) = (abs(fft(s))).^2;           % generate magnitude of FFT
	16                                          % and store as a column of S
	17  end
	18
	19  clf;
	20  plot(S);                                % plot all spectra on same graph
	21
	]]>
      </code>
      <para id="p8">
	Make sure you understand what every line in the script does.
	What signals are plotted?
      </para>
      <para id="p9">
	You should be able to describe the tradeoff between mainlobe
	width and sidelobe behavior for the various window functions.
	Does zero-padding increase frequency resolution?  Are we
	getting something for free?  What is the relationship between
	the DFT,
	<m:math>
	  <m:apply>
	    <m:ci type="fn" class="discrete">X</m:ci>
	    <m:ci>k</m:ci>
	  </m:apply>
	</m:math>, and the DTFT,
	<m:math>
	  <m:apply>
	    <m:ci type="fn">X</m:ci>
	      <m:ci>ω</m:ci>
	  </m:apply>
	</m:math>, of a sequence
	<m:math>
	  <m:apply>
	    <m:ci type="fn" class="discrete">x</m:ci>
	    <m:ci>n</m:ci>
	  </m:apply>
	</m:math>?
      </para>
    </section>
  </content>
</document>
