How can I convert a speed profile to displacement graph

조회 수: 5 (최근 30일)
Hariharan MK
Hariharan MK 2021년 2월 8일
답변: Walter Roberson 2021년 2월 8일
I have a speed graph that looks like the image below. The y-axis is in (m/s) and the x-axis is in (s). To generate the plot below i made use of 3 equations and applied the fplot function
max_spd = 4;
a = 2/3; %acceleration
fplot(@(x) (a)*x,[0 6],'g')
fplot(@(y) max_spd,[6 13.75],'g');
fplot(@(x) -(a)*x + (19.75)*(a),[13.75 19.75],'g')
How can I convert this velocity-time plot to a displacement-time graph?
so far I have this,
max_spd = 4;
a = 2/3; %acceleration
fplot(@(x) 0.5*(a*x)*x,[0 6],'k');
fplot(@(x) 4*x-(0.5*4*6),[6 13.75],'k');
fplot(@(x) 0.5*(-a)*x*x+(19.75)*a*x - (4*7.75) - (0.5*6*4),[13.75 19.75],'k');
which gives me this plot, is there a better function that will allow me to plot the displacement-time plot? Or is there a better method to perform this conversion?

채택된 답변

Walter Roberson
Walter Roberson 2021년 2월 8일
Don't use 3 functions.
max_spd = 4;
a = 2/3; %acceleration
fun = @(x) (0 <= x & x < 6) .* (a) .* x + ...
(6 <= x & x < 13.75) .* max_spd.*ones(size(x)) + ...
(13.75 <= x & x < 19.75) .* a .* (19.75-x);
fplot(fun, [0 20]); ylim([0 5])
Now you can process the single function that gives the speed into displacement, by integrating . Chances are that you will want cumulative output, so use something like cumtrapz()

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by