1function tempDir2Out = tempdir2
2%TEMPDIR2  Return temporary directory.
3%		DIR = TEMPDIR2 returns a temporary directory. If the username is
4%		contained in the directory returned by function TEMPDIR, the directory
5%		<TEMPDIR>/MATLAB is returned. Otherwise, the directory
6%		<TEMPDIR>/<USERNAME>/MATLAB is returned.
7%
8%		Markus Buehren
9%		Last modified 13.11.2007
10%
11%		See also USERTEMPDIR, GETUSERNAME.
12
13persistent tempDir2
14
15if isempty(tempDir2)
16	tempDir2 = tempdir;
17	tempDir2 = fullfile(tempDir2, [getusername '@' gethostname], 'MATLAB');
18	if ~exist(tempDir2, 'dir')
19		mkdir(tempDir2);
20	end
21end
22tempDir2Out = tempDir2;
23