How to differentiate distance in relation to time?

9 Ansichten (letzte 30 Tage)
Matas Mendelis
Matas Mendelis am 26 Mär. 2021
Kommentiert: Matas Mendelis am 26 Mär. 2021
Hello,
I am new to matllab, i want to differentiate distance (vector L ) in relation to time (vector t) to get the velocity. Then differentiate velocity in relation to time and get acceleration. And then plot acceleration over time. I know, that the values are way to small and there is a problem somewhere.
How can i tell MATLAB to differentiate in relation to time vector?
L=linspace(0,0.007,720); %distance (m)
t=linspace(0,0.0185,720); %time (s)
v=gradient(L); %velocity (m/s)
a=gradient(v); %acceleration (m/s^2)
plot(t,a); %plot acceleration over time

Akzeptierte Antwort

Jan
Jan am 26 Mär. 2021
Bearbeitet: Jan am 26 Mär. 2021
Your observation "the values are way to small" is the right way to find the problem. Find out the factor by which the result is too small. You find a relation between this value and the differences between the elements of t, e.g. t(2)-t(1).
L = linspace(0,0.007,720); %distance (m)
t = linspace(0,0.0185,720); %time (s)
v = gradient(L, t); %velocity (m/s)
% ^
a = gradient(v, t); %acceleration (m/s^2)
% ^
If you do not specify the time in gradient it is assume to have a stepsize of 1.
  1 Kommentar
Matas Mendelis
Matas Mendelis am 26 Mär. 2021
Thank you!!! As always with MATLAB, it is simple when you know what and how to type in :D

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by