tf2sos of iirnotch giving different results
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hi,
I am trying to use iirnotch() for filtering, I noticed that if I ran the coefficients from iirnotch (2nd order) through tf2sos (still comes out to be the exact same numbers), the frequency response of (b,a) and (sos) showed in freqz() or fvtool() gives very different results.
eg: [b,a] = iirnotch(wo,bw); [sos1] = tf2sos(b,a); freqz (b, a, Fs); freqz (sos, Fs);
I was wondering how come there is a difference?
채택된 답변
Star Strider
2014년 12월 11일
You didn’t post the details of your code so I can only provide a general reply. As the documentation states, the second-order-section (‘sos’) implementation of a filter characteristically produces the most stable version of the filter. The transfer function (‘tf’) is usually less stable. Therefore, the plotted filter passband-stopband characteristics may be different between the two implementations. (I convert to and use the ‘sos’ implementation whenever I design a filter.)
댓글 수: 6
Daoyuan
2014년 12월 12일
Thanks for the answer, my code is similar to the eg I gave, so for example, I was testing the notch filter for power line interference.
%60 Hz noise, at 300Hz sampling frequency
wo = 60/(300/2); bw = wo/35;
[b,a] = iirnotch(wo,bw);
fvtool(b,a);
sos = tf2sos(b,a);
fvtool(sos);
From the result of this code, the first and second graph looks completely different, the first graph having around -80dB notch with a flat band everywhere else, and the second has a wide notch of only -40dB, and with a non-flatband after the notch. However I am confused because if you look at the values in b & a versus the values in SOS, they are the exact same values:
sos = 0.98236277 -0.607133581 0.98236277 1 -0.607133581 0.96472554
b = 0.98236277 -0.607133581 0.98236277
a = 1 -0.607133581 0.96472554
However, the graph in the fvtool or freqz shows very different results. I was wondering since the notch provides a second order iir filter, and the sos is a second order iir filter, both with the same values, how are they producing different results. To my knowledge I thought the sos should produce the same results as the original iir filter if both are second order, since the tf2sos converts high order into cascaded second order filters.
Daoyuan
2014년 12월 12일
Just to update, I realized that I think the mistake I made is that when I used: fvtool(sos); I should have used: fvtool(sos(1, 1:3), sos(1, 4:6)); which would place the second half of the sos as the denominator. So I guess if I use when sos is used with freqz or fvtool, the matrix should be manually separated between numerator and denominator of IIR?
I get the same results when I plot your data with freqz. I don’t have the DSP System Toolbox so I can’t experiment with it.
I get good results with this code for your filter in both tf and sos implementations (Signal Processing Toolbox):
Fs = 300; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
Ws = [59 61]/Fn; % Stopband Limits
Wp = [57 63]/Fn; % Passband Limits
[n,Wn] = buttord(Wp, Ws, 1, 10);
[b,a] = butter(n, Wn, 'stop'); % Design Stopband Filter
[sos,g] = tf2sos(b,a);
figure(3)
freqz(b,a)
figure(4)
freqz(sos)
The filter coefficients here are:
b = [949.9142e-003 -1.1746e+000 2.2629e+000 -1.1746e+000 949.9142e-003];
a = [1.0000e+000 -1.2047e+000 2.2604e+000 -1.1444e+000 902.3386e-003];
sos = [1.0000e+000 -618.2445e-003 1.0000e+000 1.0000e+000 -554.5812e-003 949.5072e-003;
1.0000e+000 -618.2445e-003 1.0000e+000 1.0000e+000 -650.1666e-003 950.3231e-003];
g = 949.9142e-003;
Daoyuan
2014년 12월 12일
perhaps it is because the iirnotch gives a second order filter. I edited my code, and I think it is because if the sos shows a 1 row matrix, it will take the code as 1 row of 3rd order fir filter with "a" being 1? I added this code at the end of my mine and it yields the same results as fvtool(sos) or freqz(sos).
b1 = sos;
a = 1;
fvtool (b1, a);
figure
freqz (b1, a);
Star Strider
2014년 12월 12일
Your previous Comment seems to have solved the problem. Still, there seems something anomalous about the results you’re getting with the SOS implementation. Something is wrong somewhere, and it isn’t in your code.
I suggest you mention your findings to The MathWorks in a bug report. Copy and paste the URL for your Question here to your bug report so you don’t have to repeat everything.
Daoyuan
2014년 12월 15일
OK, thanks for the advice, I will try to send a bug report.
=D
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Digital Filter Design에 대해 자세히 알아보기
참고 항목
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)
