POS_TO_REAL Maps positive numbers to reals. t = pos_to_real(s) maps the positive number s to the real number t. Works as the inverse function of real_to_pos, hence pos_to_real(real_to_pos(x)) is nearly equal to x. See also REAL_TO_POS. created by Benedikt Rudolph DATE: 20-Aug-2012
0001 function t = pos_to_real(s) 0002 %POS_TO_REAL Maps positive numbers to reals. 0003 % 0004 % t = pos_to_real(s) maps the positive number s to the real number t. 0005 % Works as the inverse function of real_to_pos, hence 0006 % pos_to_real(real_to_pos(x)) is nearly equal to x. 0007 % 0008 % See also REAL_TO_POS. 0009 % 0010 % created by Benedikt Rudolph 0011 % DATE: 20-Aug-2012 0012 0013 t = zeros(size(s)); 0014 idx = (s>=1); 0015 t(idx) = s(idx)-1; 0016 t(~idx) = 1-1./s(~idx); 0017 end