필터 지우기
필터 지우기

tf2zpk vs. zp2tf

조회 수: 7 (최근 30일)
Yun Zhang
Yun Zhang 2016년 12월 20일
댓글: Vandana Rajan 2017년 2월 21일
I used tf2zpk to get zeros, poles and gain, then use zp2tf to get the transfer function, shown below. [z22,p22,k22] = tf2zpk(h22',1); [b,a] = zp2tf(z22,p22,k22); plot(h22-b');
I expect h22 is same as b but there is big difference. Did I miss anything?
Thanks,
Yun
  댓글 수: 1
David Barry
David Barry 2016년 12월 20일
Yes you forgot to upload some data so we can run the commands.

댓글을 달려면 로그인하십시오.

답변 (1개)

Vandana Rajan
Vandana Rajan 2016년 12월 23일
Hi,
There might be some issues with your 'h22'. Note that you should use tf2zpk when working with transfer functions expressed in inverse powers (1 + z-1 + z-2), which is how transfer functions are usually expressed in DSP. A similar function, tf2zp, is more useful for working with positive powers (s2 + s + 1), such as in continuous-time transfer functions.
You may try out the following
[b,a] = butter(3,.4);
fvtool(b,a,'polezero')
[z,p,k] = tf2zpk(b,a)
text(real(z)-0.1,imag(z)-0.1,'\bfZeros','color',[0 0.4 0])
text(real(p)-0.1,imag(p)-0.1,'\bfPoles','color',[0.6 0 0])
[b1,a1] = zp2tf(z,p,k)
b1 and a1 turn out to be equal to b and a.
  댓글 수: 2
Yun Zhang
Yun Zhang 2016년 12월 27일
I did use tf2zpk, as show below. clear N=4096*2;
filename = 'H0e030a.wav'; [h,fs] = audioread(filename);
h12 = h(:,1); % symetric, h21=h12, h11 = h22 h22 = h(:,2); [H22,freq] = freqz(h22',1,N,fs);
%% search for zeros inside and outside unit circle [z22,p22,k22] = tf2zpk(h22',1); % z22, p22 are column vectors
[h22b,h22a] = zp2tf(z22,p22,k22); [H22p,freq] = freqz(h22b,h22a,N,fs);
figure, semilogx(freq, 20*log10(abs([H22, H22p])));
Vandana Rajan
Vandana Rajan 2017년 2월 21일
Hi,
Computing the transfer function from a large number of zeros creates numerical problems as you multiply several roots together. The problem becomes more visible as the number of filter coefficients increases (as can be seen in this case).
It is never a good idea to directly compute the transfer function of a filter from its roots as you are trying to do in this case. Using second order sections provides a more stable filter representation. This can be observed by adding the following 2 lines of code at the end of your script, for_mathworks.m: sos = zp2sos(z22,p22,k22); fvtool(h22,1,h22b,h22a, sos) You can see how the second order section representation is comparable to the original response in the filter visualization tool output.
You can refer to the following documentation for more information about the fv tool and the 'sos' function: https://www.mathworks.com/help/signal/ref/fvtool.html https://www.mathworks.com/help/dsp/ref/sos.html
[Pasting here the mail sent from MathWorks Technical Support, so that the information can be useful for other community members too]

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Digital Filtering에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by