No BSD License  

Highlights from
LanczosFilter.m

Be the first to rate this file! 23 Downloads (last 30 days) File Size: 5.24 KB File ID: #14041
image thumbnail

LanczosFilter.m

by Carlos Adrian Vargas Aguilera

 

21 Feb 2007 (Updated 21 Feb 2007)

Low or high-pass Lanczos (cosine) signal filter.

| Watch this File

File Information
Description

Apply the Lanczos filter to a real time series, in the frequency space, i.e., using FFT which is faster than applied as a cosine filter in the time space.

Usage:
    Y = lanczosfilter(X,dT,cf,M,'low')
where
X - Time series
dT - Sampling interval (default 1)
Cf - Cut-off frequency (default half Nyquist)
M - Number of coefficients (default 100)
and 'low' or 'high' depending if you want to get the smooth or the noisy part of your data, respectively (default 'low', so it smooths).

NaN's elements are replaced by mean(X). If you have a better idea, just let me know.

It comes with an example, also take a look at the screenshot, where the filter is applied to each row.

Reference:
Emery, W. J. and R. E. Thomson. "Data Analysis Methods in Physical Oceanography". Elsevier, 2d ed., 2004. Pages 533-539.

MATLAB release MATLAB 7.1.0 (R14SP3)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
21 Feb 2007 Carlos Adrian Vargas Aguilera

Sorry, there's an error in the help. I wrote M greater is better, but it should read lower, and so, probably M=10 for default is better but this really depends on your problem.

We just have to remember that if M is high the window approximates to a boxcar (rectangle), but the Gibbs phenomenon becomes greater, which Lanczos tries to diminish!

In the screenshot, the x-axis are minutes, and there was aplied a 60-min low-pass filter to the figure at the top.

29 Sep 2008 Janaki Chandimala

the line
elseif ~(numel(varargin{3})==1) || ~isreal(varargin{3}) || (varargin{3}==round(varargin{3}))
should be corrected as
elseif ~(numel(varargin{3})==1) || ~isreal(varargin{3}) || ~(varargin{3}==round(varargin{3}))
to avoid M not being an integer. Otherwise the code works only for the default M .

01 Oct 2008 Carlos Adrian Vargas Aguilera

Thank you Yanaki. In fact I have rewritten the code, but I haven't update it yet, because I'm reorginizing all of my programs. But thank you again, you are correct.

The author

20 Oct 2010 Francis Mingo

How to make a matlab code by Lanczos method? I really didn't know how...

12 Jul 2011 huang xiaoyu

THANKING

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
filter design Carlos Adrian Vargas Aguilera 22 Oct 2008 09:01:27
filter analysis Carlos Adrian Vargas Aguilera 22 Oct 2008 09:01:27
lowpass filter Carlos Adrian Vargas Aguilera 22 Oct 2008 09:01:27
highpass filter Carlos Adrian Vargas Aguilera 22 Oct 2008 09:01:27
win Carlos Adrian Vargas Aguilera 22 Oct 2008 09:01:27
lanczos filter Carlos Adrian Vargas Aguilera 22 Oct 2008 09:01:27
smooth Carlos Adrian Vargas Aguilera 22 Oct 2008 09:01:27
filter Carlos Adrian Vargas Aguilera 22 Oct 2008 09:01:27
please help me making a code of lanczos method Francis Mingo 20 Oct 2010 13:28:17

Contact us at files@mathworks.com