フィルターのクリア

Calling a matlab script with arguments on the linux commandline

80 ビュー (過去 30 日間)
Paul
Paul 2021 年 1 月 9 日
コメント済み: Steven Lord 2021 年 2 月 3 日
I am trying to call a matlab script which takes a single argument (a file path), loads and generates plots from the data. I am hitting the "Error: Invalid use of operator." error, even though this script runs fine within a matlab GUI instance, what am I doing wrong?
(base) bash-4.2$ ~/apps/MATLAB/R2020b/bin/matlab -nosplash -nodesktop -r "~/git/oceanObs/evaluate/make_levels.m('~/Shared/200428_data_OceanObsAnalysis/200913_210216_local_robust_1950_FLRdouble_sptg_200913_79pres1000.mat');"
MATLAB is selecting SOFTWARE OPENGL rendering.
< M A T L A B (R) >
Copyright 1984-2020 The MathWorks, Inc.
R2020b Update 3 (9.9.0.1538559) 64-bit (glnxa64)
November 23, 2020
To get started, type doc.
For product information, visit www.mathworks.com.
/home/duro/git/oceanObs/evaluate/make_levels.m('/home/duro/Shared/200428_data_OceanObsAnalysis/200913_210216_local_robust_1950_FLRdouble_sptg_200913_79pres1000.mat');
|
Error: Invalid use of operator.
  3 件のコメント
Paul
Paul 2021 年 1 月 10 日
Surely, with Matlab 2020b Update 3 you can use underscores (char 95) within directory and file names? Please don't tell me that I have to add a preceding \?
Paul
Paul 2021 年 1 月 10 日
Ok that doesn't seem to be it:
(base) bash-4.2$ ~/apps/MATLAB/R2020b/bin/matlab -nosplash -nodesktop -r "make_levels.m /work/durack1/Shared/200428\_data\_OceanObsAnalysis/200913\_210216\_local\_robust\_1950\_FLRdouble\_sptg\_200913\_79pres1000.mat;"
MATLAB is selecting SOFTWARE OPENGL rendering.
< M A T L A B (R) >
Copyright 1984-2020 The MathWorks, Inc.
R2020b Update 3 (9.9.0.1538559) 64-bit (glnxa64)
November 23, 2020
To get started, type doc.
For product information, visit www.mathworks.com.
make_levels.m /work/durack1/Shared/200428\_data\_OceanObsAnalysis/200913\_210216\_local\_robust\_1950\_FLRdouble\_sptg\_200913\_79pres1000.mat;
|
Error: Invalid text character. Check for unsupported symbol, invisible character, or pasting of non-ASCII characters.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2021 年 1 月 10 日
~/apps/MATLAB/R2020b/bin/matlab -nosplash -nodesktop -r "cd('~/git/oceanObs/evaluate');make_levels('~/Shared/200428_data_OceanObsAnalysis/200913_210216_local_robust_1950_FLRdouble_sptg_200913_79pres1000.mat');"
Or better yet,
~/apps/MATLAB/R2020b/bin/matlab -batch "cd('~/git/oceanObs/evaluate');make_levels('~/Shared/200428_data_OceanObsAnalysis/200913_210216_local_robust_1950_FLRdouble_sptg_200913_79pres1000.mat');"
  8 件のコメント
Walter Roberson
Walter Roberson 2021 年 2 月 3 日
"Execute MATLAB script, statement, or function non-interactively. MATLAB:
Starts without the desktop
Does not display the splash screen
Executes statement
Disables changes to preferences
Disables toolbox caching
Logs text to stdout and stderr
Does not display modal dialog boxes
Exits automatically with exit code 0 if script executes successfully. Otherwise, MATLAB terminates with a non-zero exit code.
statement is MATLAB code enclosed in double quotation marks. If statement is the name of a MATLAB function or script, do not specify the file extension. Any required file must be on the MATLAB search path or in the startup folder.
Use the -batch option in non-interactive scripting or command line work flows. Do not use this option with the -r option.
To test if a session of MATLAB is running in batch mode, call the batchStartupOptionUsed function.
Example: -batch "myscript"
Steven Lord
Steven Lord 2021 年 2 月 3 日
MATLAB does what you tell it to do not what you want it to do. Basically whatever you specify with -r or -batch is run as though you typed it in the Command Window.
Rather than using cd as Walter did consider using the -sd startup option to specify the directory in which MATLAB should start.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by