Difference between bandpass function and butterwoth bandpass function
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
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!!
채택된 답변
Star Strider
2023년 9월 13일
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
I will try it now thank you very much!
I have another question though, I kept thinking if my minfreq, max freq and fs are in correct units? I mean, wanting the bandpass to work from 30 days to 80 days, are the units correct?
My pleasure!
If it appears to be working for you, I would not change it. The low frequency cutoff is
of a day and the high frequency cutoff is
of a day, with the sampling frequency of 1 sample/day and the Nyquist frequency being
sample/day, so if that works, use it. It makes sense from a signal processing perspective.
sample/day, so if that works, use it. It makes sense from a signal processing perspective. Thank you! I was having my doubts because the documentation of bandpass() said that the freqs must be in Hertz, and mine are in cycles/day
Im sorry I have another question. You said before that I was redesigning the filter in every iteration of the loop.
If the OLR data is 180x51x136, shouldnt I redesign the filter for every point of the grid?
Because using only the filter designed at olr(1,1,:) only works in that point right?
As always, my pleasure!
‘I was having my doubts because the documentation of bandpass() said that the freqs must be in Hertz, and mine are in cycles/day’
The examples are in Hz because that corresponds to most applications. The bandpass function does not care what the time units are, so long as the arguments make sense.
‘Because using only the filter designed at olr(1,1,:) only works in that point right?’
It works on the same size argument each time, and ‘olr(1,1,:)’ matches the arguments such as ‘olr_1(i,j,:)’ you are giving it in the loop. The argument to be filtered is not normally required to be stated in filter design, however bandpass and its friends require it as the first argument, so I supplied a representative sample in order for it to design the ‘df’ output.
Thank you so much, its all clear now!
As always, my pleasure!
Luis Jesús Olvera Lazcano
2023년 9월 13일
편집: Luis Jesús Olvera Lazcano
2023년 9월 13일
I have a last question Im so sorry.
So then, having a filter designed with olr(1,1,:) vs another one with olr(1,2,:) should give the same results applying the filter over the whole OLR (180x51x136)? Or if they're different, its too much difference?
UPDATE:
I verified the objects, they're the same :) Thank you so much for everything! Now I have better processed data
‘So then, having a filter designed with olr(1,1,:) vs another one with olr(1,2,:) should give the same results applying the filter over the whole OLR (180x51x136)?’
Yes.
‘Thank you so much for everything! Now I have better processed data’
As always, my pleasure!
.
Hello,
Thank you posting this question. I have some related questions regarding "bandpass" function, too. What is the order of the this filter? Do you mean that if add ", 'ImpulseResponse','iir'", it would function like a N-ordered Butterworth? Is there a more detailed document regarding bandpass function?
I am not sure if this is the best place to post these follow-up questions. If needed, I can open a new thread.
@xLon -- The bandpass function designs an efficient elliptic filter with ImpulseResponse='iir'. The funciton has a second output that is the actual discrete filter that it uses, so if you request the second output, you can easily see the filter it designs (and use that filter with the filtfilt functon so you do not need to re-design the filter every time if you wnat to use it in other parts of your code). It usually designs a 6-order elliptic filter, probably using the ellipord function to calculate the order.
That was fast, and that helps a lot!
Thank you!
My pleasure!
A Vote would be appreciated!
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Get Started with Signal Processing Toolbox에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
