Complimentary filtering of a signal

#### Matlab & Octave

Xf = comp_filt(X,fs,fc)	% X is a vector or matrix
or
Xf = comp_filt(X,fc)	% X is a signal structure

#### R

Xf <- comp_filt(X,fs,fc)	% X is a vector or matrix
or
Xf <- comp_filt(X,fc)	        % X is a signal list

Complimentary filtering of a signal. This breaks signal X into two or more frequency bands such that the sum of the signals in the separate bands is equal to the original signal.

Input var Description Units Default value
X is a sensor vector or matrix (i.e., with a signal in each column), or a sensor structure. N/A N/A
fs is the sampling rate of the sensor data (samples per second). fs is only needed if X is not a sensor structure. Hz N/A
fc specifies the cut-off frequency or frequencies of the complimentary filters. If one frequency is given, X will be split into a low- and a high-frequency component. If fc contains more than one value, X will be split into multiple complimentary bands. Each filter length is 4*fs/fc. Filtering adds no group delay Hz N/A
Output var Description Units
Xf is a cell array of filtered signals. There are n+1 cells where n is the length of fc. Cells are ordered in Xf from lowest to highest frequency. Each cell contains a vector or matrix of the same size as X, and at the same sampling rate as X. Hz

### Matlab & Octave

The example below uses data from the file testset1.nc. You can download it from the animaltags website's example data sets. If the file is saved in your current working directory, load it via:

testset1 = load_nc(‘testset1.nc’)
Xf = comp_filt(testset1.A.data, testset1.A.sampling_rate, 0.8)
plott(Xf{1,1}, testset1.A.sampling_rate, Xf{1,2}, testset1.A.sampling_rate)

### R

The example below uses data from the file testset1.nc. You can download it from the animaltags website's example data sets. If the file is saved in your current working directory, load it via:

testset1 <- load_nc(‘testset1.nc’)
Xf <- comp_filt(X = testset1$A$data, sampling_rate = testset1$A$sampling_rate, fc = .8)
xf <- list(Xf1 = Xf[[1]], Xf2 = Xf[[2]])
plott(xf, testset1$A$sampling_rate)