samer@0: function vn=uniquevar(x) samer@0: % uniquevar - Allocate a unique unused variable name samer@0: % samer@0: % uniquevar :: unit -> action string. samer@0: % uniquevar :: A~'initialied value' -> action string. samer@0: % samer@0: % If no initial value is given the variable is NOT allocated. samer@0: % There are up to 100000 variable names available. samer@0: samer@0: exists=1; samer@0: while exists, samer@0: vn=sprintf('t_%05d',floor(100000*rand)); samer@0: exists=evalin('base',['exist(''',vn,''',''var'')']); samer@0: end samer@0: if nargin>0, samer@0: assignin('base',vn,x); samer@0: end samer@0: samer@0: