Derivatives of graph from points
5 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
回答 (2 件)
darova
2020 年 3 月 6 日
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
0 件のコメント
Star Strider
2020 年 3 月 6 日
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!