How can I implement FFT (y-axis:Power, x-axis:Frequency) with 4 cases: Lowpass/Highpass/Band/Notch
显示 更早的评论
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
采纳的回答
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 个评论
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
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.
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.
There are different methods to design filters (Butterworth, Chebyshev...) Look at the examples in these pages
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,
更多回答(1 个)
Dear Mr. Carlos,
I have implemented FFT with 4 filters. Thanks for your support.
Best Regards, Thuan Phan
类别
在 帮助中心 和 File Exchange 中查找有关 Analog Filters 的更多信息
标签
另请参阅
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)
