MATLAB: How to run multiple m files one after another

executing multiple m files

Say I have 3 .m files in a directory
a1.m a2.m a3.m
What command should I use while creating a bat file to run the m files one after another.
I have already tried
_______________
@ echo off
matlab -nosplash -nodesktop -r "a1;exit" -logfile log1.txt
matlab -nosplash -nodesktop -r "a2;exit" -logfile log2.txt
matlab -nosplash -nodesktop -r "a3;exit" -logfile log3.txt
___________________________
But MATLAB does not continue after executing a1.m
I appreciate any help I can get with this hurdle.
- R.B.

Best Answer

I suggest call all these files through a single master file. And execute master file from command line.