Bandpass and highpass filter

1 view (last 30 days)
qwfds dsafsad
qwfds dsafsad on 1 Feb 2015
Commented: Star Strider on 2 Feb 2015
Hi I have this problem. I have this vecktor z that was given to me. I fourier transform it and get Z.
----------------------------------------------
[Z,nu]=tdftfast(z);
plot(nu, abs(Z));
----------------------------------------------
I now want to filer out all 3 peaks. For the first one I use this code:
----------------------------------------------
[b,a] = butter(10,0.1);
freqz(b,a);
dataOut = filter(b,a,z);
[Z1,nu1]=tdftfast(dataOut);
plot(nu, abs(Z1));
x=ifft(Z1);
----------------------------------------------
And get this plot witch is good: http://imageshack.com/a/img537/2999/Y3sfCD.jpg
But for the next two peaks i get some problems. I use this code for the second peak:
----------------------------------------------
[b,a] = butter(10,[0.2 0.3],'bandpass');
freqz(b,a);
dataOut = filter(b,a,z);
[Z2,nu2]=tdftfast(dataOut);
plot(nu, abs(Z2))
z2=ifft(Z2);
----------------------------------------------
But now when i plot i get this and it is all wrong: http://imageshack.com/a/img538/7708/7awCCq.jpg
It is the same thing with peak number 3. What is it that I do wrong? Don't worry about a, b, dataOut and so on since i do not run the both codes at the same time. How do I bandpass peak nr 2 and highpass peak nr 3?
I also wonder how i find the carrier frequency?
Thanks!
  5 Comments
qwfds dsafsad
qwfds dsafsad on 2 Feb 2015
I looked at it now and do i really need to know the sampling frequency? By looking at the pictures i attached in my first post i can find the carrier frequency. 0,25 for peak 2 and 0,45 for peak 3. That must be enough?
Star Strider
Star Strider on 2 Feb 2015
If you are certain that those are the actual frequencies (in Hz), you can then find their indices in the nu-vector and calculate the sampling frequency, and from it the Nyquist frequency. Again, see the documentation for details.
I have no idea what function you are using to calculate your fft, but it might describe in its documentation how it determines the ‘nu’ values and what they mean. You might be able to get the relevant information from it, if it assumes (or infers) a sampling frequency from your ‘z’ data.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!