How can I implement FFT (y-axis:Power, x-axis:Frequency) with 4 cases: Lowpass/Highpass/Band/Notch
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
Hi,
Currently I implement FFT (y-axis:Power, x-axis:Frequency) as below: (based on http://www.mathworks.com/help/matlab/math/fast-fourier-transform-fft.html)
d1=-250
d2=250
data= d1 + (d2-d1).*rand(1,256)
Fs=30
m = length(data); % Window length
n = pow2(nextpow2(m)); % Transform length
y = fft(data,n); % DFT
f = (0:n-1)*(Fs/n); % Frequency range
power = y.*conj(y)/n; % Power of the DFT
plot(f,power)
xlabel('Frequency (Hz)')
ylabel('Power')
title('{\bf Periodogram}')
Currently, I don't know how to customize source code above for Lowpass/Highpass/Band/Notch.
Please help me, thanks for your support.
Best Regards,
Thuan Phan
Accepted Answer
Carlos
on 1 Apr 2014
If you want to filter a signal in the frequency domain you just need to multiply your signals' frequency response (y in your code) by the frequency response of your filter.
In order to calcute your filter coefficients and if you have the filter design toolbox this tutorial has all the information you might need http://www.mathworks.com/tagteam/55876_digfilt.pdf
You can also design your filter using the fdatool or using the signal processing toolbox (here you can find all of the filter functions in the signal processing toolbox http://www.mathworks.es/es/help/signal/analog-filters.html)
10 Comments
Dear Mr. Carlos,
Thank you so much. Currently, I am new with this field, and I need only use matlab functions (not design tool) for FFT-Lowpass/Highpass/... with output data is two-dimension array: y-axis(Power):x-axis(Hz). I have also refered many links on Matlab. It's hard for me to find matlab functions that is related to FFT-Lowpass/Highpass/Band/Notch with y-axis(Power):x-axis(Hz).
If you know those matlab functions. Need your help. Thank you so much.
Best Regards,
Another simple approach to filter with fft is this one
f=20; % frequency
A=4;% amplitude
Fs=f*100;%sampling frequency
Ts=1/Fs;%sampling period
t=0:Ts:10/f;%time vector
x=A*sin(2*pi*f*t);%20 Hz sine wave
x2=A*sin(2*pi*(f+50)*t);70 Hz sine wave
x=x+x2;%sum of the 2 signals
plot(x)
F=fft(x);%fft of the 2 signals
figure
N=Fs/length(F);
baxis=(1:N:N*(length(x)/2-1));
plot(baxis,real(F(1:length(F)/2)))
A1=zeros(length(F),1); % generate a zeros vector of the same length as the FFT
A1(10:11)=F(10:11); %here comes the filtering with the fft,we just take the spectrum of the 50Hz signal
xr=ifft(A1); %we recover the 50Hz signal
plot(real(xr)),grid on
hope it helps
Thuan
on 1 Apr 2014
Dear Mr. Carlos,
Thanks for your support early.
I will refer your source code and link above. And I will need your help more when I meet problems about that. Thank you so much.
Best Regards,
Dear Mr. Carlos,
Currently, I have refered your link and your source code above. I can not found matlab functions that support FFT with 4 cases: Low pass, High pass, Band and Notch. And output data including two parts: + For y-axis: Power (microV or V); + For x-axis: Frequency (Hz).
Please give me other functions for support my problems above. Thank you so much.
Best Regards, (my skype: thuanpq78)
I have given you links that where you can find functions to design filters. Depending on the input parameters you can design a different type of filter. As far as you are concerned the FFT is just an algorithm to obtain your frequency response.
Your steps should be the following
1) Design your filter (depending on the type of filters low, high... you should change the imput parameters)
2)Obtain the frequency response of your filter
3)Multiply the your signals' frequency response times the filter freqeuncy response(you should do this 4 times once for ecery type of filter).
Do you mean power (Watts, W) or voltage (V) when talking about the Y-axis?
Dear Mr. Carlos,
Power is microVolt in the Y-axis. Input data is one-dimension array of values in range [-250;250] (microVolt).
Thanks for your support.
Carlos
on 1 Apr 2014
Ok. Then we are talking about voltage
Dear Mr. Carlos,
Your steps is good for me. And I need functions used for each step. It will be more clearly for me.
Thank you so much.
Carlos
on 1 Apr 2014
There are different methods to design filters (Butterworth, Chebyshev...) Look at the examples in these pages
Thuan
on 1 Apr 2014
Dear Mr. Carlos,
There are two domains to use: Digital Domain and Analog Domain. Currently, I use eeg data (in microVolt). And I will choose Digital Domain. Is this right? Thanks for your support.
Best Regards,
More Answers (1)
Thuan
on 6 Apr 2014
Dear Mr. Carlos,
I have implemented FFT with 4 filters. Thanks for your support.
Best Regards, Thuan Phan
Categories
Find more on Analog Filters in Help Center and File Exchange
Tags
See Also
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)