FFT. It doesn't seem to find the frequencies
1 次查看(过去 30 天)
显示 更早的评论
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')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/195140/image.png)
2 个评论
Adam
2018-11-15
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Measurements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!