www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/@guidarray/private/GetGUID.m

    function guids = GetGUID(numGuids)
%GETGUID Generate GUIDS
%
%  GUIDS = GETGUID( NUMGUIDS )

%  Copyright 2000-2012 The MathWorks, Inc. and Ford Global Technologies, Inc.



persistent guidStream

if ispc
    warning(message('mbc:guidarray:UsingRandomGUIDs'));
end

% Check that we have actually initialised the generator
if isempty(guidStream)
    if usejava( 'jvm' )
        sr = java.security.SecureRandom.getInstance('SHA1PRNG');
        % select a seed [0, 2^31-1] (2^31-1 is the largest possible java int)
        seed = sr.nextInt(2^31-1); 
    else
        seed = sum( clock*10 );
    end
    guidStream = RandStream('swb2712','seed',seed);
end

% Get the random guids
guids = rand(guidStream,numGuids, 1);