1

我对振动和使用 matalb fft 相当陌生。我得到了一组长度为 15000 的数据(一维数组)(不确定这是否相关),我试图弄清楚在这个数据中是否有任何波全部。我被指示可能使用 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)))

我只看到频率 = 0 的 1 次窥视,但我确信有非零频率,我做错了什么?谢谢!PS:我也不知道如何选择采样频率?请提供任何提示(请记住,我不知道原始频率)

4

1 回答 1

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')

如果一切正常,您可以通过查看stackoverflow 上的另一个 FFT 答案来更深入地了解。

于 2012-10-18T22:12:28.630 回答