-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotTrajectories.m
45 lines (40 loc) · 1.04 KB
/
plotTrajectories.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
function figNum = plotTrajectories(traj, separators)
t = traj.t;
ti = t(1);
tf = t(length(t));
titles = ["pos","vel","acc", "jerk", "snap"];
dstr = "";
tstr = "";
props = ["q","dq","ddq","dddq","ddddq"];
props = intersect(props,fieldnames(traj),'stable');
n = length(props);
dim = ceil(sqrt(n));
figRef = figure;
figNum = figRef.Number;
for i = 1:n
prop = props(i);
if ~isfield(traj,prop)
continue;
end
subplot(n,1,i);
plot(t,traj.(prop));
xlim([ti tf]);
title(titles(i));
xlabel("time (s)");
if i > 1
dstr = strcat(dstr, 'd');
end
if i == 2
tstr = '/s';
end
if (i>2)
tstr = strcat('/s^', num2str(i-1));
end
ylabel(strcat(dstr,'q ','(rad',tstr,')'));
if nargin == 2
for i=1:length(separators)
xline(separators(i), ':');
end
end
end
end