lab3 correlation.py

# lab3 correlation.py - correlation.py Introduction This...

This preview shows pages 1–3. Sign up to view the full content.

Sheet1 Page 1 ########################################################################### # # correlation.py # ########################################################################### # # Introduction # # This example covers some basic Python programming techniques, # such as functions, loops, and lists, which are demonstrated # in the context of a simple cross-correlation implementation. # ########################################################################### # # Cross-Correlation # # There are several slightly different definitions for correlation. # Some of the definitions contain normalizing scale factors. # Different implementations of correlation handle the edges of the vectors # differently (for example, some implementations zero-pad the shorter # vector in order to make the vectors the same length). # # The cross-correlation in this demo is implemented to behave like # MATLAB's "xcorr" function. The reason for this is that maintaining # some consistency with MATLAB will make it easier when switching # back and forth between MATLAB and Python. The main difference between # the Python and MATLAB implementations is that Python list indexing # begins at zero, whereas MATLAB vector indexing begins at one. # # Documentation about MATLAB's "xcorr" function can be found here: # http://www.mathworks.com/access/helpdesk/help/toolbox/signal/xcorr.html # ########################################################################### # # Python Tips # # 1. Syntax # # - Unlike C, Python does not use lots of punctuation (such as braces "{}") # to group sets of statements. Instead, it uses indentation to determine # which statements are contained in constructs such as functions and loops. # # 2. Lists # # - Use square brackets "[]" to create lists. # (Parentheses "()" are used for tuples, which are similar to lists, # but their contents cannot be modified. Use braces "{}" for # dictionaries, which are another type of data structure.) # # - Python starts indexing arrays at zero (like C), # unlike MATLAB (which starts indexing at one). #

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Sheet1 Page 2 # - Lists are one of the most basic data structures in Python. # You can index into them like arrays (using the square bracket "[]"
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 01/13/2011 for the course ECE 4305 taught by Professor Wy during the Spring '10 term at WPI.

### Page1 / 12

lab3 correlation.py - correlation.py Introduction This...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online