IIR filter from diff. equation
조회 수: 9 (최근 30일)
이전 댓글 표시
Hey,
I got a rather silly problem. I got the difference equation of a transfer function, and I need to create a filter from this. My first thought was to take the a's and b's directly from it, but if I do that, and use
bode(b,a);
I get what looks like a highpass filter, from a difference equation that is supposed to be of a lowpass. The difference equation is
y(n) = 2*y(nT-T) - y(nT-2T) + x(nT) - 2x(nT-6T) + x(nT-12T)
I'm not gonna tell you what I took a and b to be, since I think i got it wrong :-)
댓글 수: 0
채택된 답변
Wayne King
2012년 9월 28일
Perhaps you are not representing the system correctly in bode()?
A = [1 -2 1];
B = [1 0 0 0 0 0 -2 0 0 0 0 0 1];
fvtool(B,A)
댓글 수: 2
Wayne King
2012년 9월 28일
편집: Wayne King
2012년 9월 28일
No, it's not bode(A,B), the problem is that bode() is operating on the premise that you have positive powers of the variable (not negative as you have), so it's interpreting:
A = [1 -2 1];
as z^2-2z^1+1 for example.
추가 답변 (2개)
Wayne King
2012년 10월 1일
편집: Wayne King
2012년 10월 1일
This is a lowpass filter:
aLowpass = [1 -2 1];
bLowpass = [1 0 0 0 0 0 -2 0 0 0 0 0 1];
As you can see with:
fvtool(bLowpass,aLowpass,'Fs',100)
but it is not a very good one. And the highpass filter is not particular good either.
Since you have the Signal Processing Toolbox, why not design your filters with that software?
For example, say you want a lowpass Butterworth (IIR) filter for data sampled at 100 Hz and you want to lowpass everything below 10 Hz. I'll make the attenuation in the stopband 40 dB and the passband ripple 0.5 dB.
D = fdesign.lowpass('Fp,Fst,Ap,Ast',10,15,0.5,40,100);
filtobj = design(D,'butter');
fvtool(filtobj)
Now you can filter your data with:
lowpass_ecg = filter(filtobj,ecg_chan);
By the way, you are supposed to accept answers when people have answered your question.
참고 항목
카테고리
Help Center 및 File Exchange에서 Frequency Transformations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!