Borrar filtros
Borrar filtros

How to run multiple m files one after another

5 visualizaciones (últimos 30 días)
Rohan
Rohan el 26 de Oct. de 2012
Comentada: Alexandra el 4 de Nov. de 2016
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.

Respuesta aceptada

Sachin Ganjare
Sachin Ganjare el 26 de Oct. de 2012
I suggest call all these files through a single master file. And execute master file from command line.
  2 comentarios
Sachin Ganjare
Sachin Ganjare el 26 de Oct. de 2012
Create master_function.m file with contents below:
%Start of master_function.m file
diary log1.txt;a1;clear all;
diary log2.txt;a2;clear all;
diary log3.txt;a3;clear all;
%End of master_function.m file
Then use below command from commandline:
matlab -nosplash -nodesktop -r "master_function;exit" -logfile master_log.txt
Alexandra
Alexandra el 4 de Nov. de 2016
Hi PG,
How could I do this and in the end save the results and run everything again automatically?
Imagine I am running such a massive monte carlo that I am running several so that each time matrixes are not too big.
Thanks a lot.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre File Operations en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by