Just add '-wait' option to the command line: matlab -wait -nodisplay -nojvm -nosplash -nodesktop -r "Matlab_function(,);exit"
Without this option, your batch script will continue even if the matlab function hasn't finished.
You can check it by writing the command : matlab -help which gives :
-wait - MATLAB is started by a separate starter program
which normally launches MATLAB and then immediately
quits. Using the -wait option tells the starter
program not to quit until MATLAB has terminated.
This option is useful when you need to process the
the results from MATLAB in a script. The call to
MATLAB with this option will block the script from
continuing until the results are generated.
Using "-wait", you don't really need the timeout.