IIR filter from diff. equation
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Wayne King
le 28 Sep 2012
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 commentaires
Wayne King
le 28 Sep 2012
Modifié(e) : Wayne King
le 28 Sep 2012
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.
Plus de réponses (2)
Wayne King
le 1 Oct 2012
Modifié(e) : Wayne King
le 1 Oct 2012
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.
Voir également
Catégories
En savoir plus sur Frequency Transformations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!