function test_dir(path_to_dir)
% Purpose: test the existence of a directory and generate an error if it
% doesn't exist or is not a directory
%
% Variables: 
%	- path_to_dir: string of the full path of the directory to test
%	(needed)
%
% Global variables: none

% Arguments processing
if nargin ~= 1
   error('Bad number of arguments');
end

% Testing
if (~exist(path_to_dir,'dir'))
   err=sprintf('Directory %s doesnt exist or is not a directory',path_to_dir);
   error(err);
end

