How to pass variable argument using system command?

10 ビュー (過去 30 日間)
Prateek Gupta
Prateek Gupta 2018 年 3 月 7 日
コメント済み: Prateek Gupta 2018 年 3 月 7 日
x0=[45,360,45,180];
ind0=x0(1);
ind1=x0(2);
ind2=x0(3);
ind3=x0(4);
system(['python /home/prateek/matlab_R2017a_glnxa64/projects/saobjective/fh.py ind0 ind1 ind2 ind3']);
In fh.py file, I have given:
a = (sys.argv[1])
b = (sys.argv[2])
c = (sys.argv[3])
d = (sys.argv[4])
print a
ind=[a,b,c,d]
e=fitness(ind)
The problem is here print a should print 45 but it is printing ind0.

採用された回答

Walter Roberson
Walter Roberson 2018 年 3 月 7 日
fh_file = '/home/prateek/matlab_R2017a_glnxa64/projects/saobjective/fh.py'
cmd = sprintf('python "%s" %g %g %g %g', fh_file, ind0, ind1, ind2, ind3);
system(cmd)
  1 件のコメント
Prateek Gupta
Prateek Gupta 2018 年 3 月 7 日
Thanks, Worked like a charm.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeView and Analyze Simulation Results についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by