-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstick.m
37 lines (32 loc) · 892 Bytes
/
stick.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
function stick(resultfile)
% plot a stick figure of a gait cycle
% Load the result
if (nargin == 0)
[file,path] = uigetfile('*.mat');
resultfile = [path file];
end
load(resultfile);
x = result.x;
u = result.u;
dur = result.dur;
speed = result.speed;
N = size(x,2);
gait2d = result.model.gait2d; % function handle for musculoskeletal model
% Initialize the model (we need to run the model to compute GRFs and muscle forces
result.model = initmodel(result.model);
R = [1:6 4]; % right stick points
L = [2 7:10 8]; % left stick points
xmin = 1e6;
xmax = -1e6;
figure(1);clf;hold on
for i=1:5:size(x,2)
d = result.model.gait2d('Stick',x(1:50,i));
d(:,1) = d(:,1) + 0.1*(i-1);
xmin = min(xmin,d(:,1));
xmax = max(xmax,d(:,1));
plot(d(R,1),d(R,2),'b',d(L,1),d(L,2),'r');
end
plot([xmin xmax],[0 0],'k'); % draw ground surface as a black line
axis('equal');
axis('off');
hold off;