Borrar filtros
Borrar filtros

Running Matlab script from another directory

34 visualizaciones (últimos 30 días)
g
g el 22 de En. de 2019
Respondida: Walter Roberson el 22 de En. de 2019
I currently have a script with the following line. What it does is opens matlab and passes the file to mymatlabscript, then exits once the calculation is done.
matlab -nodesktop -nodisplay -r "try; existing_file = '$existfile'; mymatlabscript; end; exit"
I want to be able to run this script from another directory, outside of the directory that contains mymatlabscript and the script with the line above. How should I configure this line to be able to do that? Assume the other directory does not have mymatlabscript. Thanks!

Respuestas (1)

Walter Roberson
Walter Roberson el 22 de En. de 2019
If it is truly a script and not a function, then you would typically use run() naming the script file. However, that will cd to the directory containing the file and cd back afterwards, which might not be suitable for your needs, so you might prefer to start with addpath() the directory that the script is in.

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by