FFT produces flat Transfer Function

8 views (last 30 days)
I have a model of a neuron, which can be injected with current, and responds by generating action potentials. The sample-time step of my simulations is 0.025ms.
Preliminary simulations show that the neuron filters out frequencies of around 40-70Hz. I therefore want to obtain a transfer function for my neuron, and show that the gain dips for these frequencies. To do this I played white noise in the model, and used matlabs FFT function.
I use the following code:
% Data file N contains column 1 of time, column 2 of neuron data.
Fs = 40000; % Sampling frequency: 0.025ms=40000Hz
T = 1/Fs; % Sample time
t=N.data(:,1); % Time
v=N.data(:,2); % Data
% Sum of a 50 Hz sinusoid and a 120 Hz sinusoid
% plot(t,v);
Y = fft(v);
Y(1)=[]; % Sum of components; can be removed.
n=length(Y);
power = abs(Y(1:floor(n/2)));
nyquist = 200; % Means transfer function ranges for 0-100Hz, as desired.
freq = (1:n/2)/(n/2)*nyquist;
plot(freq,power)
Trouble is, the plot comes back completely flat, apart from a very large peak (8e5) in power for very small (0-0.1Hz) frequencies. What am I doing wrong with my MATLAB code? Should I be injecting periodic signals instead of white noise?
Thanks,
Linford

Accepted Answer

Rick Rosson
Rick Rosson on 23 Mar 2012
Why are you setting the variable nyquist to a value of 200? The Nyquist frequency should be half of the sampling rate:
nyquist = Fs/2;
Also, please comment out the line
Y(1) = [];
at least for now. If you want to eliminate the DC component, ther are better ways to do so. But before you do, it is helpful to start out with the complete spectrum and then decide if it is a good idea.
Next, it will be easier to work with an even number of samples. Please modify these two lines
t=N.data(:,1); % Time
v=N.data(:,2); % Data
so that they become:
t=N.data(1:end-1,1); % Time
v=N.data(1:end-1,2); % Data
Finally, please modify the computation of the frequency domain:
dF = Fs/n;
freq = 0:dF:Fs/2-dF;
These changes might not resolve this issue completely, but thy should help in figuring out what is going on.

More Answers (2)

Rick Rosson
Rick Rosson on 23 Mar 2012
What is the value of n=length(Y)?

Amaya
Amaya on 30 Dec 2014
I had the same problem with some data I was analysing. This problem seems to be caused by th DC offset of the signal which I removed by doing
your_signal=your_signal-mean(your_signal)
and then performing any fft operation on it. I am not sure why this happens (mathematically), but would love to know if anyone has an answer!. Thanks.

Tags

Community Treasure Hunt

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

Start Hunting!