Time normalization in FFT!
조회 수: 7 (최근 30일)
이전 댓글 표시
Hi everyone,
I'm trying to take a FFt from a time signal being resulted from an ODE procedure for simulating an imbalance response of a rotor-bearing system in a specific rotational speed. I am a little bit confused after having the fft signal because I can see the pick but not at the right frequency in Herz (theoretically I should see the pick at a frequency equal to rotaional speed of the shaft), I guess something is wrong with time normalization by timesignal but I don't know what exactly:
%
z=Y(:,1); %Timesignal
N=length(z); %Number of samplerates
ts=51/51000; %Sampletime
Fs=1/ts %Samplefrequency
fB = Fs/2;
Yc = fft(z)/N;
YY = 2 * abs( Yc( 1:N/2+1 ) );
YY(1) = YY(1)/2;
f = fB * linspace(0, 1, N/2+1)/0.05882;
Many thanks in advance!
댓글 수: 1
Daniel Armyr
2016년 2월 2일
I am curious at the number 0.05882. It seems like an oddly specific hard-coded value. Are you sure it is the right value there, and that this is not a number that should be computed from for example ts or Fs?
답변 (1개)
Star Strider
2016년 2월 2일
In order to use the fft with your ODE integration, you have to use a vector of fixed values for ‘tspan’, rather than the adaptive times reported by the differential equation solvers. The easiest way to do this is to use the linspace function:
tspan = linspace(t_start, t_end, 500);
This creates a 500-element vector of equally-spaced time values between the values you choose for ‘t_start’ and ‘t_end’.
댓글 수: 2
Star Strider
2016년 2월 2일
You don’t need to. If you choose enough time points, you will get adequate frequency resolution. I linked to the R2015a documentation on fft in my original Answer, and I’m linking to it here as well. Note specifically the code between the top two plot figures as to how to correctly use the sampling time difference to correctly calculate the frequency vector and plot the fft.
Example code:
s = ... SIGNAL ...
L = length(s); % Length Of Signal
Ts = tspan(2)-tspan(1); % Sampling Time Interval
Fs = 1/Ts; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
FTs = fft(s)*2/L; % Calculate FFT
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector (Hz)
Iv = 1:length(Fv); % Index Vector
figure(1)
plot(Fv, abs(FTs(Iv)))
grid
참고 항목
카테고리
Help Center 및 File Exchange에서 Spectral Estimation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!