CxFIRNarrowBandFilter
Advanced Analysis Library Only
AnalysisLibErrType CxFIRNarrowBandFilter (NIComplexNumber inputArray[], ssize_t numberOfElements, FIRCoefStruct filterInformation, NIComplexNumber outputArray[]);
Purpose
Filters the complex input sequence using the FIR narrowband filter specified by the filterInformation structure.
The overall filter is a linear-phase FIR filter. This function calculates the delay for the filter using the following equation:
where NG is the number of elements in the model filter array, NI is the number of elements in the image suppressor array, and M is the value of interpolation.
You can design narrowband FIR filters using FIRNarrowBandCoef, and then implement the filtering using CxFIRNarrowBandFilter. The design and implementation are separate operations, because many narrowband filters require long design times, whereas the actual filtering is very fast and efficient. Keep this in mind when creating your narrowband filtering diagrams.
Example Code
/* Filter a complex input signal using a FIR narrowband filter. */
NIComplexNumber x[128], y[457];
double input[128];
double fs, fbp, fbs, fc, ripple, atten;
FIRCoefStruct coefinfo;
ssize_t n;
int i;
n = 128;
fs = 1000.0;
fbp = 10;
fbs = 20;
fc = 200;
ripple = 0.01;
atten = 60.0;
WhiteNoise(n, 1, 17, input);
for(i = 0; i < n; i++){
x[i].real = input[i];
x[i].imaginary = input[i];
}
FIRNarrowBandCoef(fs, fbp, fbs, fc, ripple, atten, LOWPASS, &coefinfo);
CxFIRNarrowBandFilter(x, n, coefinfo, y);
Parameters
Input | ||
Name | Type | Description |
inputArray | NIComplexNumber [] | Array that contains the raw data to filter. |
numberOfElements | ssize_t | Number of elements in inputArray. |
filterInformation | FIRCoefStruct | Pointer to the FIR filter structure that contains the filter coefficients and the internal filter information. The definition of the FIR filter coefficients is as follows: typedef struct { int fltType; // filter type that you use to determine how to filter the data: // LOWPASS (0): Lowpass filter. // HIGHPASS (1): Highpass filter. // BANDPASS (2): Bandpass filter. // BANDSTOP (3): Bandstop filter. // WBLOWPASS (4): Wideband lowpass filter for cutoff frequencies near Nyquist. // WBHIGHPASS (5): Wideband highpass filter for cutoff frequencies near zero. int interp; // Interpolation factor. The model filter is stretched by interp times. int Mtaps; // Size of *Mtaps. double *Mcoef; // Coefficients of the model filter. int Itaps; // Size of *Itaps. double *Itaps; // Coefficients of the filter image suppressor } FIRCoefStruct, *FIRCoefPtr; You must allocate this structure by calling FIRNarrowBandCoef. |
Output | ||
Name | Type | Description |
outputArray | NIComplexNumber [] | Array that contains the output of the FIR filtering operation. If the interpolation factor of FIR equals 1, the size of outputArray must be at least numberOfElements + Mtaps – 1. If the interpolation factor of FIR does not equal 1, the size of outputArray must be at least numberOfElements + (Mtaps–1) * interp + Itaps – 1. |
Return Value
Name | Type | Description |
status | AnalysisLibErrType | A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants. |
Additional Information
Library: Advanced Analysis Library
Include file: analysis.h
LabWindows/CVI compatibility: LabWindows/CVI 2012 and later