Error: Unexpected MATLAB operator on Cluster

Hi Everyone,
I'm very new to matlab programming language.
I have a directory "example_first" in which there are few matlab scripts and some input files on which I want to run the functions given in matlab scripts.
example_first
├──input.score
├──input.param
├──input.expr
├──shortmain.m
├──input.m
├──dist.m
I'm using linux terminal and on cluster (workload manager is Slurm) I created a shell script like below to submit the job.
#!/bin/bash
#SBATCH --cpus-per-task=8
#SBATCH --mem-per-cpu=4G
#SBATCH --time=05:59:59
cd /home/documents/example_first
ml MATLAB/r2016a
matlab -nodisplay -nosplash -nojvm -r "run shortmain.m"
matlab -r 'shortmain(/home/documents/example_first/input.expr, /home/documents/example_first/input.score, /home/documents/example_first/input.param, Trans)'
Submitted the job like this:
sbatch test.sh
In the slurm.out file I see like following:
MATLAB is selecting SOFTWARE OPENGL rendering.
Opening log file: /home/java.log.41769
< M A T L A B (R) >
Copyright 1984-2016 The MathWorks, Inc.
R2016a (9.0.0.341360) 64-bit (glnxa64)
February 11, 2016
To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.
Academic License
shortmain(/home/documents/example_first/input.expr, /home/documents/example_first/input.score, /home/documents/example_first/input.param, Trans)
|
Error: Unexpected MATLAB operator.
Can anyone please help me how to resolve this error. This is the first time I'm using matlab.
Any help is appreciated. thanq.

2 件のコメント

lu wang
lu wang 2019 年 3 月 20 日
My guess is that it might related to how you pass the variables to your function inside the batch.
what is the Trans in your last function variable?
your code:
matlab -nodisplay -nosplash -nojvm -r "run shortmain.m"
matlab -r 'shortmain(/home/documents/example_first/input.expr, /home/documents/example_first/input.score, /home/documents/example_first/input.param, Trans)'
try this :
matlab -nodisplay -nosplash -nojvm -r "shortmain"
and put the path inside your shortmain.m by:
addpath('/home/documents/example_first/')
open and load the input.score, input.param inside the shortmain.m
hope this helps
Lu
venkat K
venkat K 2019 年 3 月 20 日
編集済み: venkat K 2019 年 3 月 20 日
sorry, basically "shortmain.m" is matlab script in which shortmain function is given. I want to execute this shortmain function on the input.expr, input.score, input.param files. "Trans" is a name I should mention which is related to files, without this the function wont work.
Should I try the way you mentioned above?

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

 採用された回答

Walter Roberson
Walter Roberson 2019 年 3 月 20 日

1 投票

matlab -r 'shortmain(''/home/documents/example_first/input.expr'', ''/home/documents/example_first/input.score'', ''/home/documents/example_first/input.param'', ''Trans'')'
or
matlab -r 'shortmain("/home/documents/example_first/input.expr", "/home/documents/example_first/input.score", "/home/documents/example_first/input.param", "Trans")'
or
matlab -r "shortmain('/home/documents/example_first/input.expr', '/home/documents/example_first/input.score', '/home/documents/example_first/input.param', 'Trans')"

5 件のコメント

venkat K
venkat K 2019 年 3 月 20 日
I tried this way already. I got the below error:
Error: The input character is not valid in MATLAB statements or expressions.
Edric Ellis
Edric Ellis 2019 年 3 月 21 日
That error is because in R2016a, the double-quote character isn't valid. It can be tricky to get the quotes completely correct in these situations - but in this case, you could try to take advantage of MATLAB's command-dual syntax, and do something like
matlab -r "shortmain /home/documents/example_first/input.expr /home/documents/example_first/input.score /home/documents/example_first/input.param Trans"
Walter Roberson
Walter Roberson 2019 年 3 月 21 日
Good point about R2016a and quotes.
My first and third should have worked in R2016a though.
venkat K
venkat K 2019 年 3 月 21 日
Wowww thanks a lot Edric Ellis. You are absolutely right and worked without any error. Thanks a lot again.
venkat K
venkat K 2019 年 3 月 21 日
Yes Walter Roberson, first and third of yours also worked for me. Yesterday, I tried the second and didn't try the other. Thanks a lot.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

製品

質問済み:

2019 年 3 月 20 日

コメント済み:

2019 年 3 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by