function compileDir2(path2compile)

if nargin<1
   path2compile = fullfile(pwd,'util');
end

files=dir(fullfile(path2compile,'*.cpp'));
gut=0;
bad=0;

for k=1:length(files)
   isValid = isRealMexFile(fullfile(path2compile,files(k).name));
   if isValid ==1
      try
         mex('-v','-g',fullfile(path2compile,files(k).name))
         gut=gut+1;
      catch
         bad=bad+1;
      end
   end
end
fprintf('erfolgreich %d, nicht compiliert %d\n',gut, bad);

%filesError = compileFiles({files.filepath});

function isMexfile=isRealMexFile(filepath)
%TODO:do regexp to capture isolated word only
string=file2string(filepath);
isMexfile=any(strfind(string,'mexFunction'));
