Subplotting error with velocity vs time graph

조회 수: 1 (최근 30일)
jack knipler
jack knipler 2016년 5월 23일
편집: dpb 2016년 5월 23일
Hi i am having trouble with plotting a graph for velocity vs time. We have to change the velocity from m/s to km/h and the time from seconds to hours. For some reason when we plot them, they are both straight lines along the x axis. This is our code:
subplot(2,2,3)
t=data(:,1);
thour=t/3600
dkm=displacement/1000
vel=dkm/thour;
plot(thour,vel);
title('Velocity Vs Time:')
ylabel('Velocity (km/h)')
xlabel('Time (h)')

채택된 답변

dpb
dpb 2016년 5월 23일
vel=dkm./thour;
Need the dot operator here...
  댓글 수: 1
dpb
dpb 2016년 5월 23일
편집: dpb 2016년 5월 23일
That's indeterminate from the info available...but I suspect your formulation of dividing by the time vector may be be the culprit. You probably actually need a constant dt for the base conversion. Dividing by an increasingly smaller t at the origin will eventually lead to 1/0-->Inf which it appears is what you have in the plot.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by