blob: 5df13df27ada0f1685f8c9de1b9acd57a14166d0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
function n = normalize(data)
if (size(data, 1) == 1)
data = data';
end
_min = repmat(min(data), size(data, 1), 1);
_max = repmat(max(data), size(data, 1), 1);
equals = (_min == _max);
if any(any(equals))
_min(equals) = 0;
% Prevent division by zero, and devide by 1
_max(_max == 0) = 1;
end
n = (data - _min) ./ (_max - _min);
end
|