我对振动和使用matalb fft相当新。我得到一组长度为15000的数据(1D数组)(不确定这是否相关)我试图弄清楚是否有任何波浪埋藏在根据这些数据。我被指示可能使用matlab fft。这是正确的方法吗?我期待看到什么?我真的不确定如何解释我会得到的任何结果。 请让我知道你们的想法。 谢谢,如果需要更多细节,我会提供。 例如:
% Df=[array is given to me and it is of size 15000];
% t=[time used for the above array, and if it is of the same size, also provided to me]
N_0= length(t);
fs_0=length(Dfxz);
Y_0=fft(Dfxz,N_0);
k_0=-N_0/2:N_0/2-1;
%Find the phase angle
p_0 = (angle(Y_0));
R_0 = norm(Y_0);
ff_0 = (0:length(Y_0)-1)'/length(Y_0)*100; % Frequency vector
FT_power1_0 = abs(Y_0);
plot(k_0*fs_0/N_0,fftshift(abs(Y_0)))
我只看到1次频率= 0,但我确信有非零频率,我做错了什么? 谢谢! PS:我不知道如何选择采样频率?任何提示请(请记住,我不知道原始频率)
答案 0 :(得分:4)
试试我的版本。在我看来,您拥有在数据中找到频率峰值所需的所有信息(如果存在)。如果所有你能看到的是零频率的大峰值,你可能会有一个巨大的DC偏移,它会淹没你所有的其他数据。我在我的代码中提出了一个补救措施。 。
x = randn(15000,1); %//This is the data you were given - I'll use noise for demonstration - replace x with your Df data
%//If youre getting a massive peak at zero that dwarfs everything else, you
%//probably have a large DC offset. Easily removed in the time domain using
%//the following ..
x = x-mean(x);
tAxis = linspace(3/15000,3,15000); %//You said you have this too - I'll make up something for demonstration - make sure you replace this with your t data
dt = diff(tAxis(1:2)); %//sample period from time axis
fs = 1/dt;%//sample rate from sample period
NFFT = numel(x); %//number of fft bins - change if you like
Y = abs(fft(x, NFFT)).^2; %power spectrum
%//Calculate frequency axis
df = fs/NFFT;
fAxis = 0:df:(fs-df);
%//Plot it all
figure; plot(fAxis(1:NFFT/2), Y(1:NFFT/2))
xlabel('Frequency in Hz')
ylabel('Power')
如果确定无误,您可以通过查看another FFT answer on stackoverflow来深入了解。