-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLocationMap.m
78 lines (73 loc) · 2.2 KB
/
LocationMap.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
66
67
68
69
70
71
72
73
74
75
classdef LocationMap
properties (SetAccess = public)
mapMatrix
end
%properties (SetAccess = protected)
% %
%end
methods
%constructor
function obj = LocationMap(mapMatrix)
obj.mapMatrix = mapMatrix;
end
%operators
function mapC = plus(mapA, mapB)
mapC = LocationMap(mapA.mapMatrix + mapB.mapMatrix);
end
function mapC = minus(mapA, mapB)
mapC = LocationMap(abs(mapA.mapMatrix - mapB.mapMatrix));
end
function divMap = rdivide(map, scalar)
divMap = LocationMap(round(map.mapMatrix / scalar));
end
function divMap = mrdivide(map, scalar)
divMap = LocationMap(round(map.mapMatrix / scalar));
end
%overloaded functions
function fbool = isnane(mapList)
fbool = repmat(false, size(mapList));
end
function fbool = isfinite(mapList)
fbool = repmat(true, size(mapList));
end
function sumMap = sum(mapList)
sumMap = mapList(1);
for n = 2:length(mapList)
sumMap = sumMap + mapList(n);
end
end
function meanMap = mean(mapList)
meanMap = sum(mapList) / length(mapList);
meanMap.mapMatrix = round(meanMap.mapMatrix);
end
function mapMat = repmat(map, numRows, numCols)
mapCol = map;
for n = 2:numCols
mapCol = [mapCol , map];
end
mapMat = mapCol;
for n = 2:numRows
mapMat = [mapMat ; mapCol];
end
end
%class-specific functions
function d = mapDistance(mapA, mapB)
d = 0;
[burstRowsA, burstColsA] = find(mapA.mapMatrix == 1);
[burstRowsB, burstColsB] = find(mapB.mapMatrix == 1);
for nA = 1:length(burstRowsA)
%d = d + min(abs(burstRowsB - burstRowsA(nA)) + ...
% abs(burstColsB - burstColsA(nA)));
d = d + min(sqrt((burstRowsB - burstRowsA(nA)).^2 + ...
(burstColsB - burstColsA(nA)).^2));
end
for nB = 1:length(burstRowsB)
%d = d + min(abs(burstRowsA - burstRowsB(nB)) + ...
% abs(burstColsA - burstColsB(nB)));
d = d + min(sqrt((burstRowsA - burstRowsB(nB)).^2 + ...
(burstColsA - burstColsB(nB)).^2));
end
d = d / (length(burstRowsA) + length(burstRowsB));
end
end
end