PDA

View Full Version : FILTUP inaccuracy



hcrisp
06-20-2011, 03:07 PM
I am experimenting with FILTUPDESIGN and FILTUP, but the results are less than spectacular. Am I doing something wrong, or is the error in the routines themselves? The filter doesn't seem to perform as well as the one in MATLAB's interp.m function (http://www.mathworks.com/help/toolbox/signal/interp.html), so I'm wondering if the FILTUP output itself has quantization effects.



nin = 40L
t = findgen(nin)/20.
y = sin(2*!PI*3.*t)
ratio = 30
nout = (nin - 1) * (ratio - 1) + nin

; get the results using FILTUP
h = filtupdesign(ratio, 4, 1.0)
tup = findgen(nout)/(20.*ratio)
yup = filtup(h, y, ratio)

; now calculate the theoretical
tdes = tup
ydes = sin(2*!PI*3.*tdes)

; compare
plot, tup, yup, psym=3
oplot, t, y, psym=4, color=140
oplot, tdes, ydes, color=230
; not exactly a perfect sine wave!

hcrisp
06-21-2011, 09:49 AM
Looked into this further, and I think the bad result is due to the value of 1.0 that I am passing for the "alpha" argument. MATLAB's interp.m sets the default at 0.5 and WAVE's sets it at 1.0. "Alpha" is the normalized cutoff frequency and ranges from 0.0 to 1.0. A default of 0.5 is probably better.



; this change gives better results
h = filtupdesign(ratio, 4, 0.5)


The disadvantage of lowering the alpha cutoff is that frequencies above that will be attenuated/removed. So there is an inherent trade-off. Raising the filter order can help, but it can only do so much when aliasing is involved (for alpha=1.0 in particular).