How can i plot the data for specific time intervals?
49 次查看(过去 30 天)
显示 更早的评论
Am trying to plot vehicle trajectories(time-space plots) using following data. I have plotted all the vehicles for whole time duration of 15 minutes.Now I need to Plot it for particular time periods( for e.g.,between 100 sec and 400 sec) for all vehicle numbers in that time interval.How can i select the data only for a particular time interval and plot for all vehicles in a single figure?
Data format: Veh_no 2 2 2 2 2 2 ..3 3 3 3 3 3... 4 4 4 4... time(sec) 0 0.1 0.2 0.3 0.4 0.5 ..0.2 0.3 0.4 0.5 0.6 0.7...0.1 0.2 0.3 0.4 distance(m) 0 0.2 0.5 0.8 0.9...0.3 0.4 0.7 0.9 1.3 1.5...0.2 0.4 0.8 1.1...
0 个评论
采纳的回答
KSSV
2017-6-16
Check the below code:
t =0:0.01:2*pi ;
x = sin(t) ;
plot(t,x)
%%draw data only between 2 and 4
idx = (t>2 & t <=4) ;
hold on
plot(t(idx),x(idx),'.r')
You can get logicals of the indices which you want to plot, and use these logical indices for plotting.
2 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!