FFT. It doesn't seem to find the frequencies
2 views (last 30 days)
Show older comments
Hi, Im having a lot of issues turning my time domain into a frequency domain. What am I doing wrong? I expect some high frequency noise - also outside of 500 Hz, and the fft only shows frequencies around 0 Hz...
%% Load data
load('henrikrigtigforsoeg.mat')
data1 = data(1:20000)*0.0049;
fs = 1000; % Sampling frequency
time = 1/fs;
leng = 20000; %length of signal
t = (0:leng-1)*time % Time vector
%% Cut the data
kont_1 = data1(3000:7000); %Contraction 1
t_y1 = (0:4000)*time; %time vector for contraction 1
leng_k1 = length(kont_1); %length of the contraction
%% FFT
Y1 = fft(kont_1); % Lav en FFT på data
P2_y1 = abs(Y1/leng_k1);
P1_y1 = P2_y1(1:leng_k1/2+1);
P1_y1(2:end-1) = 2*P1_y1(2:end-1);
f_y1 = fs*(0:(leng_k1/2))/leng_k1;
%% Plot data
figure
subplot(2,1,1) % Plot the raw data
plot(t_y1,kont_1)
title('Contraction in time-domain')
xlabel('Time in seconds')
ylabel('Magnitude in V')
subplot(2,1,2) % Plot the Fourier transformation
plot(f_y1,P1_y1)
title('Single-sided power spectrum of first contraction')
xlabel('Frequencies in Hz')
ylabel('Power in V')
2 Comments
Adam
on 15 Nov 2018
A high frequency component at 0 means your data is very badly zero-centred. If you subtract the mean from your data this should go away.
Answers (0)
See Also
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!