view matlab/db/uniquevar.m @ 14:e1f87438e34c

Work around for lock-up when used by triserver project. By god it's ugly but it seems to work.
author samer
date Thu, 02 Feb 2012 03:01:20 +0000
parents 0dd31a8c66bd
children
line wrap: on
line source
function vn=uniquevar(x)
% uniquevar - Allocate a unique unused variable name
%
% uniquevar :: unit -> action string.
% uniquevar :: A~'initialied value'  -> action string.
%
% If no initial value is given the variable is NOT allocated.
% There are up to 100000 variable names available.

	exists=1;
	while exists,
		vn=sprintf('t_%05d',floor(100000*rand));
		exists=evalin('base',['exist(''',vn,''',''var'')']);
	end
	if nargin>0,
		assignin('base',vn,x);
	end