MATLAB Answers

Plotting trajectories for each time step

89 ビュー (過去 30 日間)
Hari krishnan
Hari krishnan 2018 年 11 月 9 日
コメント済み: Hari krishnan 2018 年 11 月 9 日
I have the trajectory of an object moving in a plane with the time of detection, X and Y coordinates of the object. I am able to plot the coordinates and the final trajectory of the object as shown in the figure. What should i do, if i need to see each step in the movement trajectory of the object rather than the final trajectory (like sort of an animation)? The mat file is attached with this, the first column corresponds to the time, second and third column corresponds to X and Y coordinates respectively. Any help to solve this will be appreciated.
time_of_detections = finaL_plot_matrix_cell{1,4}(2:end,1);
X_coordinate_ant13 = finaL_plot_matrix_cell{1,4}(2:end,2);
Y_coordinate_ant13 = finaL_plot_matrix_cell{1,4}(2:end,3);
plot(X_coordinate_ant13,Y_coordinate_ant13,'r');

  0 件のコメント

サインインしてコメントする。

採用された回答

KSSV
KSSV 2018 年 11 月 9 日
編集済み: KSSV 2018 年 11 月 9 日
load('required_information_for_trajectories.mat')
t = data(:,1) ;
x = data(:,2) ;
y = data(:,3) ;
idx = t>=220.20 ;
t = t(idx) ;
x = x(idx) ;
y = y(idx) ;
h = plot3(t(1),x(1),y(1)) ;
axis([min(t) max(t) min(x) max(x) min(y) max(y)])
for i = 1:length(t)
set(h,'Xdata',t(1:i),'Ydata',x(1:i),'Zdata',y(1:i)) ;
drawnow
end

  3 件のコメント

Hari krishnan
Hari krishnan 2018 年 11 月 9 日
@KSSV thank you very much, this is what exactly was looking for. I would like to ask one more question. If i want to search for a specific time (say 220.20) and just to start plotting trajectories from that specific time, is there a way to proceed?
KSSV
KSSV 2018 年 11 月 9 日
Edited the answer.....
Hari krishnan
Hari krishnan 2018 年 11 月 9 日
Thank you very much.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by