Skip to Main Content Skip to Search
Product Documentation

idealfilter - Class: timeseries

Apply ideal (noncausal) filter to timeseries object

Syntax

ts1 = idealfilter(ts, interval, filtertype)
ts1 = idealfilter(ts, interval, filtertype, index)

Description

ts1 = idealfilter(ts, interval, filtertype) applies an ideal filter of filtertype to one or more frequency intervals that interval specifies for the timeseries object, ts.

ts1 = idealfilter(ts, interval, filtertype, index) applies an ideal filter and uses the optional index integer array to specify the columns or rows to filter.

Tips

Input Arguments

ts

The timeseries object to which you want to apply an ideal filter.

interval

The frequency interval (specified in cycles per time unit) at which you want the ideal filter applied. To specify several frequency intervals, use an n-by-2 array of start and end frequencies, where n represents the number of intervals.

filtertype

A string specifying the type of filter you want to apply, either pass or notch.

index

An integer array that specifies the columns or rows to filter when ts.IsTimeFirst is true.

Output Arguments

ts1

The timeseries object that results when you apply an ideal filter to the original timeseries object.

Definitions

ideal filter

Filters are ideal in the sense that they are not realizable. An ideal filter is noncausal and the ends of the filter amplitude are perfectly flat in the frequency domain.

Examples

These examples first apply an ideal notch filter to the data in count.dat. Then, they apply a pass filter to the data:

% Load the count matrix into the workspace:

load count.dat;

% Create a timeseries object from column one of this matrix. 
% Specify a time vector that ranges from 1 to 24 s in 1-s intervals. 

count1=timeseries(count(:,1),1:24);

% Obtain the mean of the data:

countmean = mean(count1);

% Enter the frequency interval, in hertz, for filtering the data:
interval=[0.08 0.2];

% Invoke an ideal notch filter:
idealfilter_countn = idealfilter(count1,interval,'notch')

% Compare the original data and the shaped data on a line plot:

plot(count1,'-.'), grid on, hold on
plot(idealfilter_countn,'-')

% Restore the mean to the filtered data and show it on the line plot, 
% adding a legend and a title:

countn_restored = idealfilter_countn + countmean;
plot(countn_restored,':m');
title('Notch Filter')
legend('Original Data','Shaped Data','Mean Restored',...
       'Location','NorthWest')

% Close the Figure window:
close 
% Then, repeat the process using a pass rather than a notch filter:
figure
plot(count1,'-.'), grid on, hold on
idealfilter_countp = idealfilter(count1,interval,'pass');
plot(idealfilter_countp,'-')
countp_restored = idealfilter_countp + countmean;
plot(countp_restored,':m');
title('Pass Filter')
legend('Original Data','Shaped Data','Mean Restored',...
       'Location','NorthWest')

See Also

filter | timeseries

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS