-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathparse.m
More file actions
50 lines (42 loc) · 1.04 KB
/
parse.m
File metadata and controls
50 lines (42 loc) · 1.04 KB
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
49
50
%% parse x and y positions from txt file
% Name of the file
filename = 'large_trajectory.txt';
A = textread(filename, '%s', 'whitespace', '');
string = A{1,1};
k = strfind(string,"x: ");
l = strfind(string,"y: ");
for idx = 1:length(k)
for i = 1:30
if string(k(idx)+2+i) ~= ' '
X(idx,i) = string(k(idx)+2+i);
else
break
end
end
end
for idx = 1:length(l)
for i = 1:30
if string(l(idx)+2+i) ~= ' '
Y(idx,i) = string(l(idx)+2+i);
else
break
end
end
end
for i = 1:length(X(:,1))
x_pose(i) = str2num(X(i,:));
y_pose(i) = str2num(Y(i,:));
end
comp_even = ones(1,length(x_pose));
comp_uneven = ones(1,length(x_pose));
comp_even(1:2:end) = 0;
comp_uneven(2:2:end) = 0;
if sum(x_pose == comp_uneven) == 0
x_pose(1:2:end) = [];
y_pose(1:2:end) = [];
elseif sum(x_pose == comp_even) == 0
x_pose(1:2:end) = [];
y_pose(1:2:end) = [];
else
warning("something went wrong")
end