-
Notifications
You must be signed in to change notification settings - Fork 0
/
somrow.m
65 lines (45 loc) · 1.54 KB
/
somrow.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
%INIT
clear;
load('session_1_2.mat');
load('energies_1_2.mat');
is_map = 0;
recordstart = 0;
thisstroke = [];
sprint = session.sprint;
labellist = genvarname(labels(sprint));
for k = 1:32
temp = data(sprint);
eval([labellist{k} '= temp(k,:);']);
end
%Run data with classification
for i = 2000:(length(energy.phases))
if((energy.phases(i-1) == 4) && (energy.phases(i) == 1))
if recordstart == 0
recordstart = 1;
else
if is_map == 0;
%Init som
nrnodes = 20;
somlength = length(thisstroke);
map = som(thisstroke, nrnodes);
scatter(map.nodes(1,:), map.nodes(2,:)), hold on
plot(thisstroke(1,:), thisstroke(2,:))
axis([0, 0.3, -1.2, 0.8]);
pause(0.05);
end
%Save stroke and train
map = map.add(thisstroke);
map = map.adapt(100);
is_map = 1;
clf;
scatter(map.nodes(1,:), map.nodes(2,:)), hold on
plot([map.nodes(1,:),map.nodes(1,1) ], [map.nodes(2,:),map.nodes(2,1)], 'g'), hold on
plot(thisstroke(1,:), thisstroke(2,:))
axis([0, 0.3, -1.2, 0.8]);
pause(0.05);
end
%Start new stroke
thisstroke = [];
end
thisstroke = [thisstroke,[L_alpha(i),L_phi(i)]'];
end