usando la línea de comando para llamar a 2 archivos matlab, donde el segundo archivo depende del primero

I have two .m files. first file does the initialzation and load some data. second .m file is a function and depends on the first file.

Llamo matlab -nojvm -r "firstFile;secondFile(args);exit" y funciona.

but now I want to call 2nd function file several times while only call 1st file once in the beginning.

matlab -nojvm -r "firstFile;exit"

matlab -nojvm -r "secondFile(args);exit" no funciona.

¿Cómo puedo hacer eso?

preguntado el 12 de febrero de 14 a las 08:02

2 Respuestas

Assuming you want to stick with specifying stuff on the command line rather than writing out a separate script, you could do:

matlab -nodisplay -r "firstFile; for idx = 1:7, secondFile(args); end, exit"

Respondido 12 Feb 14, 08:02

Cada vez que llamas al matlab command, you're starting a new instance of Matlab. Previously used variables won't be available on subsequent calls. Instead just open a command line instance on Matlab once:

matlab -nojvm -nosplash -r
for i=1:1000

Una vez que llame al matlab command, you can type any Matlab-syntax commands you want into the command line, just like you would with the Matlab GUI.

Respondido 12 Feb 14, 08:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.