Admin Production ni-theme
Current Publication

CxIIRCascadeFiltering

LabWindows/CVI

CxIIRCascadeFiltering

Advanced Analysis Library Only

AnalysisLibErrType CxIIRCascadeFiltering (NIComplexNumber xArray[], ssize_t numberOfElements, IIRFilterPtr filterInformation, CxIIRFilterStatePtr filterState, NIComplexNumber yArray[]);

Purpose

Filters the complex input sequence using the cascade IIR filter specified by the filterInformation structure. Each of the IIR cascaded stages is second order for lowpass and highpass filters, and fourth order for bandpass and bandstop filters.

filterInformation is the pointer to the filter structure that contains the filter coefficients and the internal filter information. You must allocate this structure by calling AllocIIRFilterPtr and then calling one of the cascade IIR design functions before you call CxIIRCascadeFiltering.

The filterInformation structure contains the internal filter state information for the filtering operation so you can call CxIIRCascadeFiltering in a loop to continually filter new input array data and produce new output filtered data.

If you finish filtering one set of input data and want to filter a completely new data set, call ResetIIRFilter before you call CxIIRCascadeFiltering with the new data. ResetIIRFilter causes the internal filter state information to clear before the next filtering operation.

Example Code

/* Generate a random complex signal and filter it using a designed cascade lowpass Butterworth IIR filter. */
NIComplexNumber x[256], y[256];
double input[256];
double fs, fc;
int type, order;
ssize_t n;
IIRFilterPtr filterInfo = NULL;
CxIIRFilterStatePtr state = NULL;

n = 256;
fs = 1000.0;
fc = 200.0;
order = 5;
type = LOWPASS;
WhiteNoise (n, 1, 17, input);
for(int i = 0; i < n; i++){

x[i].real = input[i];
x[i].imaginary = input[i];

}

filterInfo = AllocIIRFilterPtr(type, order);
state = AllocCxIIRFilterStatePtr(type, order);

if(filterInfo != 0 && state != 0) {

Bw_CascadeCoef(fs, fc, 0.0, filterInfo);
CxIIRCascadeFiltering(x, n, filterInfo, state, y);
FreeIIRFilterPtr(filterInfo);
FreeCxIIRFilterStatePtr(state);

}

Parameters

Input
Name Type Description
xArray NIComplexNumber [] Array that contains the raw data to filter.
numberOfElements ssize_t The number of points in both the input and output arrays.
filterInformation IIRFilterPtr Pointer to the filter structure that contains the filter coefficients and the internal filter information.

You must allocate this structure by calling AllocIIRFilterPtr and then calling one of the cascade IIR design functions before calling this function.
filterState CxIIRFilterStatePtr Pointer to the filter structure that contains the internal filter information.

You must allocate this structure by calling AllocCxIIRFilterStatePtr and free this structure by calling FreeCxIIRFilterStatePtr.
Output
Name Type Description
yArray NIComplexNumber [] Array that contains the output of the IIR filtering operation. The size of this array must be at least numberOfElements.

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