function directory=MatlabFolder
% directory=MatlabFolder
% 
% MatlabFolder is obsolete. Use MATLABROOT instead.
% 
% Return the path to the main Matlab folder, eg 'Savoca:Applications:Matlab 5.2.1:'.
% We follow the Matlab 5 convention of leaving the trailing filesep
% character at the end of the directory's path.
%
% Also see FULLPATH and FILEPARTS. Matlab defines the string "root" to
% be the root directory (i.e. the name of the disk on which Matlab resides).
%
% Denis Pelli 5/26/96

% 1/2/00 dgp Use Matlab 5 "fullfile" and "pathsep" to simplify code.

warning('MatlabFolder is obsolete. Use MATLABROOT instead.');
paths=path;
while 1
	if isempty(paths)
		error('Can''t find the Matlab folder');
	end
	[directory,paths]=strtok(paths,pathsep);	% grab next directory (ie path)
	ii=findstr(lower(directory),fullfile('toolbox','matlab','general'));
	if ~isempty(ii)
		directory=directory(1:min(ii)-1);
		break;
	end
end
