Derivatives of graph from points

Hello,
I'm a highschool teacher. And one of my student is currently working on the position, velocity and acceleration of the road surface of a bridge.
He has the following point from his bridge:
Position = [0 0.5 1 2 3 4 5 6 7 8 9 9.5 10]; % in cm
Time = [0 0.25 0.5 0.75 1 1.25 1.5 1.75 2 2.25 2.5 2.75 3]; % in seconds
Is it posible to create a position-time graph from this points and then create the first derivative (velocity-time graph) and after this the second derivative (acceleration-time graph)?
I ask this question, because we're having some problems with finding the mathmatical function of the first graph.
If there is an other way of solving this problem, we are open for suggestions!
With Regards
Hans Vertongen and the student of GO! Campus De Brug, Belgium

답변 (2개)

darova
darova 2020년 3월 6일

0 개 추천

If you timestep (0.25) doesn't change use gradient
velocity = gradient(Position,Time);
Use diff if timestep is different
velocity = diff(Position)./diff(Time);
t1 = Time(2:end) - diff(Time)/2; % new time for velocity
Star Strider
Star Strider 2020년 3월 6일

0 개 추천

To calculate derivatives of a vector or matrix, use the gradient function:
Position = [0 0.5 1 2 3 4 5 6 7 8 9 9.5 10]; % in cm
Time = [0 0.25 0.5 0.75 1 1.25 1.5 1.75 2 2.25 2.5 2.75 3]; % in seconds
h = mean(diff(Time)); % Constant Sampling Interval
dPdt = gradient(Position,h); % Veolcity
d2Pdt2 = gradient(dPdt,h); % Acceleration
figure
plot(Time, Position)
hold on
plot(Time, dPdt)
plot(Time, d2Pdt2)
hold off
grid
legend({'Position', 'Velocity', 'Acceleration'}, 'Location','NW')
Here, the sampling interval is constant. If the sampling interval is varying, calculate the derivatives as:
dxdt = gradient(x) ./ gradient(t);
where ‘x’ is the dependent variable and ‘t’ is the independent variable. Alternatively, use the resample funciton to resample the vector to a constant sampling interval.

카테고리

도움말 센터File Exchange에서 Vector Fields에 대해 자세히 알아보기

질문:

2020년 3월 6일

답변:

2020년 3월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by