forked from lawrennd/GPmat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mocapConnections.m
48 lines (43 loc) · 1.33 KB
/
mocapConnections.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
47
48
function connect = mocapConnections(fileName, pointNames);
% MOCAPCONNECTIONS Give a connection matrix for the motion capture data.
% FORMAT
% DESC load a connection matrix for txt file based mocap data.
% ARG fileName : the file from which to load the connectivity data.
% ARG pointNames : the names of the points in the file, with the
% ordering matching orderings in any data files to be loaded in (as
% returned by MOCAPPARSETEXT).
%
% SEEALSO : mocapLoadTextData, mocapParseText
%
% COPYRIGHT : Neil D. Lawrence, 2005, 2006
% DATASETS
fid = fopen(fileName);
i = 1;
rem = fgets(fid);
while(rem ~= -1)
[token, rem] = strtok(rem, ',');
connections{i, 1} = fliplr(deblank(fliplr(deblank(token))));
[token, rem] = strtok(rem, ',');
connections{i, 2} = fliplr(deblank(fliplr(deblank(token))));
i = i + 1;
rem = fgets(fid);
end
connect = zeros(length(pointNames));
fclose(fid);
for i = 1:size(connections, 1);
for j = 1:length(pointNames)
if strcmp(pointNames{j}, connections{i, 1}) | ...
strcmp(pointNames{j}, connections{i, 2})
for k = 1:length(pointNames)
if k == j
break
end
if strcmp(pointNames{k}, connections{i, 1}) | ...
strcmp(pointNames{k}, connections{i, 2})
connect(j, k) = 1;
end
end
end
end
end
connect = sparse(connect);