File Exchange

image thumbnail


version 1.2 (6.25 KB) by

Store persistent list of BUTTER parameters for faster access

1 Download


View License

ButterParam - Fast parameters for a digital Butterworth filter

The calculation of filter parameters with BUTTER is expensive. Therefore ButterParam stores calculated parameters in a lookup-table to accelerate repeated calls with the same input.
x = rand(10000, 1); % test data
[B, A] = butter(3, 0.6);
y = filter(B, A, x);
The relation of the processing times is: BUTTER=68% / FILTER=32%!
With [B, A] = ButterParam(3, 0.6) we get: ButterParam=14% / FILTER = 86%, and the both calls together use 35% of the version with BUTTER.

Input and output equal the BUTTER command of the Signal-Processing-Toolbox
when used with 3 inputs and 2 outputs:
[B, A] = ButterParam(N, Wn, Pass)
N: Order of the filter.
Wn: Cutoff frequency, scalar or [1x2].
Pass: Optional, 'low', 'high', 'bandpass', 'stop'.

B, A: Coefficients for FILTER.

New parameters are calculated by BUTTER (Signal-Processing-Toolbox).
The list of calculated parameters can be saved to a MAT file for future access.
If all used parameters are found in this MAT file, the SPT is not needed to
get the Butterworth filter parameters.

Run the included unittest function uTest_ButterParam to check validity and speed.

Comments and Ratings (2)

Jan Simon

Jan Simon (view profile)

Thanks for finding this bug. I'm using faster replacements for testing the existence of files or folders, but in this submission "exist(myPrefFile, 'file')" is needed. An update is comming soon.


Thanks for this tool.
In line 55 of ButterParam.m you are using

if FileExist(myPrefFile)

This function does not exist in my matlab-installation.
Exchanging it with

if exist(myPrefFile,'file')

works fine though.



Bugfix: FileExist -> exist('file')

MATLAB Release
MATLAB 7.8 (R2009a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video