This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


timeseries ideal filter


tsout = idealfilter(tsin,interval,filtertype)
tsout = idealfilter(tsin,interval,filtertype,ind)



tsout = idealfilter(tsin,interval,filtertype) applies an ideal (noncausal) filter of type filtertype to the frequency intervals specified by interval for a timeseries object tsin.

Ideal filters are noncausal, and the ends of the filter amplitude are flat in the frequency domain. The data in ts must have zero mean.

tsout = idealfilter(tsin,interval,filtertype,ind) optionally specifies the row or column indices of tsin to apply the filter to.


collapse all

First apply an ideal notch filter to a timeseries object, then apply a pass filter.

Load the data in the file count.dat, and create a timeseries object from the matrix count.

load count.dat
tsin = timeseries(count(:,1),1:24);

Compute the mean of the data in tsin.

tsinmean = mean(tsin);

Define the frequency interval, in hertz, for filtering the data.

interval = [0.08 0.2];

Invoke an ideal notch filter.

tsoutnotch = idealfilter(tsin,interval,'notch');

Compare the original data and the filtered data.

hold on

Restore the mean to the filtered data.

tsoutnotchmean = tsoutnotch + tsinmean;
title('Notch Filter')
legend('Original Data','Filtered Data','Mean Restored',...
hold off 

Repeat the filtering process using a pass filter.

hold on
tsoutpass = idealfilter(tsin,interval,'pass');

tsoutpassmean = tsoutpass + tsinmean;
title('Pass Filter')
legend('Original Data','Filtered Data','Mean Restored',...

Input Arguments

collapse all

Input timeseries with zero mean, specified as a scalar.

  • If tsin is nonuniformly sampled, then idealfilter resamples the data on a uniform time vector before applying the filter.

  • idealfilter replaces any NaN elements of tsin using the interpolation method associated with tsin prior to applying the filter.

Data Types: timeseries

Frequency interval, specified as a two-column matrix where each row represents the start and end frequencies for each interval.

Data Types: double | single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Filter type, specified as one of the following options:

  • 'pass' — Allow variations in a specific frequency range

  • 'notch' — Remove variations in a specific frequency range

Data Types: double | single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Row or column indices, specified as a positive integer numeric scalar or vector. ind represents column indices for column-oriented data (tsin.IsTimeFirst is true) and represents row indices for row-oriented data (tsin.IsTimeFirst is false).

Data Types: double | single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

See Also


Introduced before R2006a