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 Center および File ExchangeSimulation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by