![]() This discrepancy comes about because they completely ignored the roll-off of the smoothing operation (see red line), and assumed that it would be flat zero. However, the operation has completely changed the nature of the frequency components in the original signal. Sure, the drift close to 10Hz is almost nil. Smoothing and filtering are two different operations, and although they're similar in some regards (moving average is a low pass filter), you can't simply substitute one for the other unless it you can be sure that it won't be of concern in the specific application.įor example, implementing Daren's suggestion on a linear chirp signal from 0-25kHz, sampled at 100kHz, this the frequency spectrum after smoothing with a Gaussian filter So to zero-phase filter with Hd, use the filtfilthd file available on the Mathworks file exchange site However, this does not accept dfilt objects. If you want zero phase distortion, use filtfilt. To use the filter on your data, you can either do filter(b,a,data) or filter(Hd,data) depending on what filter you eventually use. You can build upon these examples and mine to design a filter according to what you want. The MATLAB documentation also has good examples on designing filters. The approach is similar for butter and ellip, with equivalent buttord and ellipord. Now if you look at the characteristics of this filter, you'll see that all the poles lie inside the unit circle (hence stable) and matches the design requirements Hd=dfilt.df2sos(s,g) %# create a dfilt object. =zp2sos(z,p,k) %# create second order sections Here's how for the same filter as above: =cheby2(n,Astop,fstop) To get a more stable filter with your exact design requirements, you'll need to use second order filters using the z-p-k method instead of b-a, in MATLAB. Now if you look at the zero-pole diagram using zplane(b,a), you'll see that there are several poles ( x) lying outside the unit circle, which makes this approach unstable.Īnd this is evident from the fact that the frequency response is all haywire. N=cheb2ord(fpass,fstop,Rpass,Astop) %# calculate minimum filter order to achieve these design requirements Rpass=1 %# max permissible ripples in stopband (dB) fpass= %# passbandįstop= %# frequency where it rolls off to half power To further illustrate my point, consider the following band pass filter. To see why this is so, you can read the wiki articles on IIR filters, especially the part on stability. By unstable, I mean you will have poles that lie outside the unit circle. Unlike FIR filters where you can increase the order of the filter with the only ramification being the filter delay, increasing the order of IIR filters will make the filter unstable. The thing to remember about IIR filters is that they've got poles. Do you need extremely sharp cut-off corners, i.e., anything a little beyond the passband is detrimental to your analysis? If so, you should use Elliptical filters. ![]() ![]() Are you trying to kill frequencies in the stopband, and you won't mind a minor loss in the response in the passband? Then you will need something that's smooth in the stop band (Cheby1). Are you trying to get a clean signal with little to no losses? Then you need something that gives you a smooth response in the passband (Butterworth/Cheby2). The choice of filter will depend entirely on your application. In Chebyschev, you get steeper roll off, but you have to allow for irregular and larger ripples in one of the bands, and in Elliptical, you get near-instant cut off, but you have ripples in both bands. In the above figure, it takes from 0.4 to about 0.55 to get to half power. In Butterworth, you get no ripples, but the frequency response roll off is slower. So in all three cases, you have to trade something for something else. The following image is taken from wikipedia. In Chebyschev, you have a smooth response in either the passband (type 2) or the stop band (type 1) and larger, irregular ripples in the other and lastly, in Elliptical filters, there's ripples in both the bands. For example, Butterworth is maximally flat in the passband and the response rolls off in the stop band. Wikipedia is a good place to start reading up on the different filters and what they do. Since you mentioned Butterworth, Chebyschev and Elliptical filters, I'm assuming you're looking for IIR filters in general. There are several filters that can be used, and the actual choice of the filter will depend on what you're trying to achieve.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |