Filter löschen
Filter löschen

Running Matlab script from another directory

34 Ansichten (letzte 30 Tage)
g
g am 22 Jan. 2019
Beantwortet: Walter Roberson am 22 Jan. 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!

Antworten (1)

Walter Roberson
Walter Roberson am 22 Jan. 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.

Kategorien

Mehr zu Search Path finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by