function tf = loadvars(filename, varargin)
% Loads variables from a file.
%
% See also: load

% Copyright 2012 Levente Hunyadi

if exist(filename, 'file')
	% read data from file
	vars = load(filename, varargin{:});

	% check whether all variables have been loaded
	tf = all(isfield(vars, varargin));

	if tf
		% assign variables in caller context
		for k = 1 : numel(varargin)
			assignin('caller', varargin{k}, vars.(varargin{k}));
		end
	end
else
	tf = false;
end
