-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert2interval.m
26 lines (24 loc) · 988 Bytes
/
convert2interval.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
function intervalincrement = convert2interval( values, max, ...
bincount, min )
% CONVERT2INTERVAL converts the vector VALUES into a length of VALUES
% times ( INTERVALS + 2 ) matrix.
% The range from MIN (excluded) to MAX (included) is split into BINCOUNT
% many equivalent bins. Underflows (including exact values of MIN) are put
% in the first bin (underflow bin), overflows in the last bin (overflow
% bin).
% The first inputs are mandatory. Default for BINCOUNT and MIN are set by
% FINDINTERVALBIN.
%
% Copyright 2021, C. Minz. BSD 3-Clause License.
if nargin < 3
[ bins, bincount ] = findintervalbin( values, max );
elseif nargin < 4
bins = findintervalbin( values, max, bincount );
else
bins = findintervalbin( values, max, bincount, min );
end
intervalincrement = zeros( length( values ), bincount );
for i = 1 : length( values )
intervalincrement( i, bins( i ) ) = 1;
end
end