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!

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!