Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Idl-pvware > Confusion about...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 5398 of 6020
Post > Topic >>

Confusion about the filter in time and frequency domain

by "duxiyu@[EMAIL PROTECTED] " <duxiyu@[EMAIL PROTECTED] > Feb 5, 2008 at 05:39 AM

Dear all,

There is an example about the signal filter which is given in this
group.
But I have some questions about it, and I hope that anyone can
unpuzzle them.
The code of the example is as follows:

; Time domain
freq1=2.
freq2=3.
freq3=4.
dtime=0.1
ntime=1000
time=dtime*findgen(ntime)
signal=sin(2*!pi*freq1*time)+sin(2*!pi*freq2*time)+sin(2*!
pi*freq3*time)

; Frequency domain
nfreq=ntime/2+1
freq=findgen(nfreq)/(dtime*ntime)
fsignal=fft(signal)

; Time domain Filter
f_low = 0
f_high = 2.5
timefilter = DIGITAL_FILTER(f_low*2*dtime, f_high*2*dtime, 50.,40)
signal=convol(signal,timefilter)

; Time domain Filter in Frequency domain
ntime2=n_elements(timefilter)
nfreq2=ntime2/2+1
freq2=findgen(nfreq2)/(dtime*ntime2)
ftimefilter=fft(timefilter,1); == ntime2*fft(timefilter)

; Frequency domain filter (instead of time domain filter)
steep=50.
freqfilter= 1./(1.+(freq/f_high)^steep)
fsignal*=freqfilter

; Plot
window,0
plot,freq,abs(fsignal[0:nfreq-1])^2,xtitle='frequency',ytitle='spectrum',title='Time
domain filtered'
window,1
plot,freq,abs((fft(signal))
[0:nfreq-1])^2,xtitle='frequency',ytitle='spectrum',title='Freq domain
filtered'
window,2
plot,freq,abs(freqfilter)^2,yrange=[0,1.1],ystyle=1,xtitle='frequency',ytitle='spectrum',title='Filters'
oplot,freq2,abs((ftimefilter)[0:nfreq2-1])^2,col=128



In this example, max(abs(fsignal[0:nfreq-1])^2) = 0.249995 and
max(abs((fft(signal))[0:nfreq-1])^2) = 0.211242.
The peak of spectra in window 0 is not equal to it in window 1.
Does this difference between them result from the arithmetical errors
of the filters?
Is there any methods to eliminate it?

> ftimefilter=fft(timefilter,1); == ntime2*fft(timefilter)
Besides, I don't know why you use the inverse transform instead of the
forward transform in IDL to caculate ftimefilter.


Du
 




 2 Posts in Topic:
Confusion about the filter in time and frequency domain
"duxiyu@[EMAIL PROTE  2008-02-05 05:39:57 
Re: Confusion about the filter in time and frequency domain
Wox <nomail@[EMAIL PRO  2008-02-05 15:38:09 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 17:10:55 CDT 2008.