Signal Processing LibraryProgram name: zero_crossings Language: C In file: parameter_lib.c Objective: Calculate number of zero crossings in window of data Usage: void zero_crossings(double *d_window_i, int window_size, FILE *outfile); Parameters:
Mathematical Description: Comments: Routine is used to calculate the zero crossings in a window (array of data) Code: void zero_crossings(double *d_window_i, int window_size, FILE *outfile) { int l, sgn[MAX_WINDOW_SIZE+1]; int count=0; if(window_size >= MAX_WINDOW_SIZE) { fprintf(stderr, "Please increase MAX_WINDOW_SIZE in window_lib.h to at least %d\n", window_size+1); exit(1); } for(l = 0; l < window_size; l++) { if(d_window_i[l] >=0.0) { sgn[l] = 1; } else { sgn[l] = -1; } } for(l = 1; l < window_size; l++) { count += abs(sgn[l] - sgn[l-1]); } fprintf(outfile,"%d\n", count/2); } |
English Version > Documents and tutorials > D.Sc. projects > Routines for DSP > parameter_lib >