Fourier Transform - position to velocity derivative

6 vues (au cours des 30 derniers jours)
Sunny Math
Sunny Math le 10 Jan 2016
Commenté : Sunny Math le 15 Jan 2016
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)

Réponse acceptée

Mona Mahboob Kanafi
Mona Mahboob Kanafi le 12 Jan 2016
Modifié(e) : Mona Mahboob Kanafi le 12 Jan 2016
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 commentaire
Sunny Math
Sunny Math le 12 Jan 2016
Thank you very much for your reply. No, I don't think its the same what I am looking for. Please go through the below clear explanation of my problem.

Connectez-vous pour commenter.

Plus de réponses (1)

Sunny Math
Sunny Math le 12 Jan 2016
I have samples of values on position along X and Y axis w.r.t time. I want to find Velocity and acceleration values from position values. For example: For X axis:
T = 0.0017sec; %Time increment(samples for second)
t = [0:0.0017:16.15]'; %Time for 9500 samples(Transpose of Row Vector since X is a Column Vector)
fs = 1/T; %Sample rate in Hertz
X = (9500x1 double); %Position values along X-axis
L = length(X); %Length of Samples along X
dx = diff(X); %Derivative of X along axis
dt = diff(t); %Derivative of t
V_x = dx./dt; %Velocity
dt2 = (dt(1:end-1)+dt(2:end))/2; %Second derivative of t
A_x = diff(V_x)./dt2; %Acceleration
Once I have values of Velocity and Acceleration, I have carried out the FFT over the values,
FFT_V_x = fft(V_x); %Fourier Transform
FFT_V_x_magnitude = abs(FFT_V_x); %Absolute Values
df = fs/L; %Frequency increment
f = -fs/2:df:fs/2-df; %Create the frequency axis
plot(f,FFT_V_x_magnitude)
I am not sure about the frequency axis for Velocity and acceleration since it involves differentiation for both. Kindly suggest me the steps if I am wrong.
  6 commentaires
Mona Mahboob Kanafi
Mona Mahboob Kanafi le 14 Jan 2016
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.
Sunny Math
Sunny Math le 15 Jan 2016
Ok. I have gone through some articles on FFT on matlab community. Please find an attachment for the sample Excel sheet. The samples are with respect to position over time. Two columns refer along X and Y axis respectively . Kindly carry on the successive derivatives for velocity and acceleration (say for example along X-axis) and following FFT. Please give your valuable feedback on your valuation. Please attach plots. Thank you very much.

Connectez-vous pour commenter.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by