-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint_trajectory.m
47 lines (41 loc) · 1.11 KB
/
print_trajectory.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
%Visualize trajectory x in relative and absolute coordinates.
%For flag==1 points with matching colors (locally) corresponds to
%the same moment in time (in absolute coords graph).
function print_trajectory(x,t,flag)
x_s = zeros(length(t), 4);
x_s = absolute_coords(x_s, t);
x_abs = absolute_coords(x, t);
figure(1);
plot(t, x);
grid on;
xlabel('t');
legend('position x', 'position y', 'velocity x', 'velocity y')
figure(2);
hold on;
plot(x(:,1), x(:,2));
plot(x(1,1), x(1,2), 'g*');
plot(x(end,1), x(end,2), 'r*');
grid on;
xlabel('position x');
ylabel('position y');
title('Relative coords');
color = 'rgby';
figure(3);
hold on;
if (flag)
for i=50:50:length(t)
plot(x_abs(i,1), x_abs(i,2),strcat('-',color(mod(i/50,4)+1),'*'));
plot(x_s(i,1), x_s(i,2),strcat('-',color(mod(i/50,4)+1),'*'));
end
else
plot(x_abs(1,1), x_abs(1,2), 'g*');
plot(x_abs(end,1), x_abs(end,2), 'r*');
plot(x_s(1,1), x_s(1,2), 'b*');
plot(x_s(end,1), x_s(end,2), 'b*');
plot(x_abs(:,1), x_abs(:,2));
plot(x_s(:,1), x_s(:,2));
end
grid on;
xlabel('position x');
ylabel('position y');
title('Absolute coords')