cross_corr

cross_corr - cross_corr.c 1/7 18 February 1999, 17:19:10...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
cross_corr.c 1/7 18 February 1999, 17:19:10 CST 1 /* 2 Cross-Correlation Speed Sensor Code. 3 4 */ 5 6 # include <stdio.h> 7 # include <time.h> 8 # include <stdlib.h> 9 # include <memory.h> 10 long random ( void ); /* This should be in the include file but isn’t. */ 11 12 # define WINDOW 100 /* Number of samples to compare. */ 13 # define DIST 1.0 /* Distance between sensors, in meters. */ 14 # define SIZE 1000 /* Number of samples to store. */ 15 # define SAMPLE_INTERVAL 0.01 /* Time between reading sensors, in seconds. */ 16
Background image of page 1

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

View Full DocumentRight Arrow Icon
cross_corr.c 2/7 18 February 1999, 17:19:10 CST 16 /* Find delta that yields best match. */ 17 18 int best_match ( int * samp_A , int * samp_B , int size ) 19 { 20 int delta = 0; 21 double lowest_err = 0; /* Initialize only to eliminate compiler warnings. */ 22 int best_delta = -1; 23 24 for ( delta = 0; delta < size - WINDOW; delta++ ){ 25 double this_err = 0; /* Error for this delta. */ 26 int i ; 27 28 /* Compute error by summing absolute value of differences. */ 29 for ( i = delta; i < delta + WINDOW; i++ ) 30 this_err += abs( samp_A[i] - samp_B[i-delta] ); 31 32 /* See if error for this delta is smaller than all previous. */ 33 if ( best_delta == -1 || this_err < lowest_err ) { 34 lowest_err = this_err; 35 best_delta = delta; 36 }} 37 38 return best_delta; 39 } 40
Background image of page 2
cross_corr.c
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/11/2011 for the course EE 4770 taught by Professor Staff during the Fall '99 term at LSU.

Page1 / 7

cross_corr - cross_corr.c 1/7 18 February 1999, 17:19:10...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online