Run cmd command from MATLAB

Hi
I want to use a MATLAB command to run a command in windows cmd.
For example I need to run this command:
C:\Program Files\prism-4.5\bin>prism test.sm -mdp -noprobchecks -exporttrans poll2.tra
This is a command to use external software called Prism and the output of this command is the file "poll2.tra".
I tried to use this command:
system(['set PATH=' C:\Program Files\prism-4.5\bin>' && 'prism test.sm -mdp -noprobchecks -exporttrans poll2.tra])
but it does not work.

1 件のコメント

amin
amin 2020 年 2 月 13 日
Problem is solved.
Now I use this command:
system('prism test.sm -mdp -noprobchecks -exporttrans poll2.tra')
and I moved test.sm file to the current folder of Matlab and it works now.
Although I prefered to use other folder path.
Anyway, its solved!

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

回答 (2 件)

Jon
Jon 2020 年 2 月 12 日

0 投票

The system command can definitely be used for this purpose. I suspect that your problem is with the string you are passing the command. I would first verify directly in the command window that the command as written is correct. If that is ok, then I suspect the problem is with the included quotation marks. Please see this link from @Image Analyst for some help with that
Rik
Rik 2020 年 2 月 12 日

0 投票

You should not set the PATH, but you should use cd instead to change the directory inside your system call.
I personally prefer to write my code to a temporary bat file, which gives you some more flexibility in writing the code.

カテゴリ

ヘルプ センター および File ExchangeSearch Path についてさらに検索

質問済み:

2020 年 2 月 12 日

コメント済み:

2020 年 2 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by