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

📄 removefilesemaphore.m

📁 This contribution provides functions for finding an optimum parameter set using the evolutionary alg
💻 M
字号:
function removefilesemaphore(semaphore)
%REMOVEFILESEMAPHORE  Remove semaphore after file access.
%		REMOVEFILESEMAPHORE(SEMAPHORE) removes the semaphore(s) set by function
%		SETFILESEMAPHORE to allow file access for other Matlab processes.
%
%		Example:
%		sem = setfilesemaphore('test.mat');
%		% access file test.mat here
%		dir test.mat.semaphore.*
%		removefilesemaphore(sem);
%
%		Markus Buehren
%		Last modified 21.12.2008
%
%		See also SETFILESEMAPHORE.

checkWaitTime = 0.1;

% remove semaphore files
for fileNr = 1:length(semaphore)
	if existfile(semaphore{fileNr})
		
			% do not use function deletewithsemaphores.m here!
			
			% sometimes deletion permission is not given, so try several times to
			% delete the file

			warnID = 'MATLAB:DELETE:Permission';
			warnState = warning('query', warnID);
			warning('off', warnID);

		fileDeleted = false;
		for attemptNr = 1:10
				lastwarn('');
			try
				delete(semaphore{fileNr}); %% file access %%
				if isempty(lastwarn)
					fileDeleted = true;
					break
				end
			catch
				% wait before checking again
				pause(checkWaitTime);
			end
			end
			warning(warnState);

			if ~fileDeleted
				% try one last time with display of warning message
				delete(semaphore{fileNr});

		end
	end
end

⌨️ 快捷键说明

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