I created a velocity(y-axis) vs time(x-axis) graph for a car acceleration code. You input constants that go into equations and outputs a graph. Sometimes it's hard to tell at what time the graph hits 60mph. I have a horizontal line at 60mph but how do I make a line that knows when velocity hits 60mph and draws a vertical line corresponding to the time?

 채택된 답변

Ameer Hamza
Ameer Hamza 2020년 5월 1일

0 개 추천

Without your code, it is difficult to suggest an exact solution, but here is the outline of the method.
[~, idx] = min(abs(velocity-60)); % velocity is vector from your code
t_60 = t(idx); % t is time vector from your code
% then write following line after other plotting statements
yline(t_60) % vectical line at t=t_60

댓글 수: 2

Chetan Roshan
Chetan Roshan 2020년 5월 1일
this helps thanks
Ameer Hamza
Ameer Hamza 2020년 5월 1일
I am glad to be of help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

태그

질문:

2020년 5월 1일

댓글:

2020년 5월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by