Difference between bandpass function and butterwoth bandpass function

17 visualizaciones (últimos 30 días)
Hi
So I've been using a bandpass filter over netcdf (OLR variable) data to extract only 30-80 days frequencies. The code has been working very well:
frecuencia_min = 1 / 80; % Min frequency (cycle/day)
frecuencia_max = 1 / 30; % Max frequency (cycle/day)
%% Bandpass OLR
olr_real = zeros(length(lon),length(lat),length(time));
tic
for i=1:length(lon)
for j=1:length(lat)
olr_real(i,j,:) = bandpass(squeeze(olr_1(i,j,:)),[frecuencia_min frecuencia_max],1); % data is daily so fs=1
fprintf('[%d] y [%d]\n',i,j);
end
end
toc
And it works perfectly, although its quite long, having dimensions 180x51x136. So I was wondering whats the difference between this function and the butter function. Which one is more efficient? How would you do this code but with the butter function?
Thanks!!

Respuesta aceptada

Star Strider
Star Strider el 13 de Sept. de 2023
I always use the 'ImpulseResponse','iir' name-value pair when using bandpass or its friends. That forces it to design a vewry efficient elliptic filter, that is probably the most computationally-efficient discrete filter available (at least in the MATLAB Signal Processing Toolbox). Otherwise, its default is (frequently) a FIR filter. FIR filters have their strengths (such as being able to have multiple passbands and stopbands, or being able to have specific characteristics such as provided by firls), however are usually not the best option.
The Butterworth design as an IIR filter, so similar to the elliptic filter bandpass designs if required to do so.
I would simply use your existing code, adding the 'ImpulseResponse','iir' name-value pair to create a more efficient IIR filter.
Also, you are re-designing the filter with every iteration of the loop. The bandpass function and its friends have a second ‘digital filter’ output, so it is probably better to do something like this:
[olr_real,df] = bandpass(squeeze(olr_1(1,1,:)),[frecuencia_min frecuencia_max],1, 'ImpulseResponse','iir'); % data is daily so fs=1
then in the loop, something like this:
olr_real(i,j,:) = filtfilt(df, squeeze(olr_1(i,j,:)));
I cannot test that, however it should be more efficient.
.
  13 comentarios
xLon
xLon el 2 de Jun. de 2025
Editada: xLon el 2 de Jun. de 2025
That was fast, and that helps a lot!
Thank you!
Star Strider
Star Strider el 2 de Jun. de 2025
My pleasure!
A Vote would be appreciated!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with Signal Processing Toolbox en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by