フィルターのクリア

Running Matlab script from another directory

34 ビュー (過去 30 日間)
g
g 2019 年 1 月 22 日
回答済み: Walter Roberson 2019 年 1 月 22 日
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!

回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 1 月 22 日
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.

カテゴリ

Help Center および File ExchangeSearch Path についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by