⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getusername.m

📁 Multicore - Parallel Processing on Multiple Cores
💻 M
字号:
function userName = getusername
%GETUSERNAME  Get user name.
%		USERNAME = GETUSERNAME returns the login name of the current MATLAB 
%		user. Function should work for both Linux and Windows.
%
%		Markus Buehren
%		Last modified: 20.04.2008
%
%		See also GETHOSTNAME.

persistent userNamePersistent

if isempty(userNamePersistent)
	if ispc
		userName = getenv('username');
	else
		systemCall = 'whoami';
		[status, userName] = system(systemCall); %#ok
		if status ~= 0
			error('System call ''%s'' failed with return code %d.', systemCall, status);
	end
		userName = userName(1:end-1);
end

	% save string for next function call
	userNamePersistent = userName;
else
	% return string computed before
	userName = userNamePersistent;
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -