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!