IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
round_random.m
Go to the documentation of this file.
1 %>@ingroup maths
2 %>@file
3 %>@brief Now works as regular round()
4 %>
5 %> 20090501: I switched this to work exactly like round() so identical
6 %> numbers will give identical results
7 %>
8 %> This function used to round randomly either to the floor or ceiling in case an
9 %> element of x is exactly zzz.5
10 %
11 %> @param x
12 %> @return rounded x
13 function x = round_random(x)
14 
15 x = round(x);
16 
17 return;
18 
19 for i = 1:length(x)
20  if x(i) ~= floor(x(i)) && x(i)-floor(x(i)) == ceil(x(i))-x(i)
21  x(i) = round(floor(x(i))+rand());
22  else
23  x(i) = round(x(i));
24  end;
25 end;
function round_random(in x)
Analysis Session (AS) base class.
Definition: as.m:6