annotate matlab/db/uniquevar.m @ 37:89688ebc447f tip

Deprecating this repository.
author samer
date Mon, 05 Jan 2015 17:42:03 +0000
parents 0dd31a8c66bd
children
rev   line source
samer@0 1 function vn=uniquevar(x)
samer@0 2 % uniquevar - Allocate a unique unused variable name
samer@0 3 %
samer@0 4 % uniquevar :: unit -> action string.
samer@0 5 % uniquevar :: A~'initialied value' -> action string.
samer@0 6 %
samer@0 7 % If no initial value is given the variable is NOT allocated.
samer@0 8 % There are up to 100000 variable names available.
samer@0 9
samer@0 10 exists=1;
samer@0 11 while exists,
samer@0 12 vn=sprintf('t_%05d',floor(100000*rand));
samer@0 13 exists=evalin('base',['exist(''',vn,''',''var'')']);
samer@0 14 end
samer@0 15 if nargin>0,
samer@0 16 assignin('base',vn,x);
samer@0 17 end
samer@0 18
samer@0 19