Fourier Transform - position to velocity derivative
조회 수: 6 (최근 30일)
이전 댓글 표시
Hi everybody,
I am trying to do position to velocity differentiation of discrete points along X-axis and carry out the frequency response of the signal by FFT.
Can someone please help me understand how to take the frequency axis in final plot?.. Can we do this by using ODE45 or by writing a function??.. Thank you
x=9000; % the number of data points along a-axis(position based)
t = 0:0.0015:300; %(0.0015 = sampling cycle in seconds)
dx = diff(x);
dt = diff(t);
dxdt = dx./dt;
fft_dxdt = fft(dxdt); % DFT
fft_dxdt_magnitude = abs(fft_dxdt);
figure()
plot(fft_dxdt_magnitude)
댓글 수: 0
채택된 답변
Mona Mahboob Kanafi
2016년 1월 12일
편집: Mona Mahboob Kanafi
2016년 1월 12일
Hello,
Your problem when assigning frequencies to fft results is only related to the shift of frequencies. The frequencies which you have assigned are corresponded to the results of matlab fftshift (fft after being centered in zero). Therefore you have to apply fftshift to your fft results as below:
T = 0.0017; %Time increment(in second)
t = (0 : T : (16.15-T))'; % 9500 samples
fs = 1/T; %Sample rate in Hertz
N = length(t); % Number of samples
TotalTime = T * N;
df = fs/N; %Frequency increment
% df = 1/ TotalTime;
f = -fs/2: df: fs/2-df; % shifted frequencies corresponding to matlab fftshift
FFT_V_x = fft(V_x); %Fourier Transform
FFT_V_x_magnitude = abs(fftshift(FFT_V_x)); %Absolute Values
plot(f ,FFT_V_x_magnitude)
If you don't get my explanation, I again suggest you to read this link for further explanation:
And about your doubt on sampling frequency, since you haven't resample your data, your sampling frequency and therefore assigned frequecies will not change. If you later have problem that the assigned frequencies have higher number of samples than your Vx and Ax vectors, try extrapolating your velocity and acceleration, or simply add zero at the beginning and end to make them fit in size (this does not change the dominant frequency components).
Hope these helps,
-Mona
추가 답변 (1개)
Sunny Math
2016년 1월 12일
댓글 수: 6
Mona Mahboob Kanafi
2016년 1월 14일
Hello,
I couldn't download your code, but your velocity PSD looks quite normal. I think what you want to see is in logarithmic scale which you must use:
loglog(f,FFT_V_x_magnitude)
This must solve the problem, but if you still can't get what you want, you must start applying window function (bartlett, tukey,Welch,...) to your signal before applying fft like this, since your signal is not periodic for fft:
V_x = V_x .* bartlett(length(V_x))';
Also, I assumed that you know what that high peak in zero frequency means. It is just related to the mean value of your signal and you can remove signal mean value to be zero before applying fft, or otherwise you can just ignore that high peak. Hope these help you.
참고 항목
카테고리
Help Center 및 File Exchange에서 Bartlett에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!