hi, i´m trying to open the cmd.exe in matlab and to execute the dos command from matlab without writing it again in cmd.exe. how can i do this?

16 ビュー (過去 30 日間)
hi, i´m trying to open the cmd.exe in matlab and to execute the dos command from matlab without writing it again in cmd.exe. for exemple: system('cmd.exe'); dos_command = 'cd D:Erica\FASTPlanning\ '; dos(dos_command); matlab is openning cmd.exe and is waitig for a command in cmd.exe but i want matlab to execute the dos command automatically in cmd.exe

回答 (2 件)

Walter Roberson
Walter Roberson 2018 年 7 月 23 日
編集済み: Walter Roberson 2020 年 8 月 14 日
If you need to start an independent process that stays alive while MATLAB continues then use .NET or Java

Muhammad Zayed
Muhammad Zayed 2020 年 8 月 14 日
編集済み: Muhammad Zayed 2020 年 8 月 14 日
you can use:
!cmd &
it works for me to open the command window from Matlab
Moreover, if you want to excute something in the cmd, you can do it as follows (in my case I want to run an excutable called "Opensees" then type the file name)
!Opensees fileName.tcl &
All the above commands will open and run the excutable in an external commond prompt window. If you wish to run it inside Matalb command window, just remove the "&" symbol at the end.
I hope this helps.
P.S. I am using MATLAB R2018a - academic version
  1 件のコメント
Walter Roberson
Walter Roberson 2020 年 8 月 14 日
My reading of the question was that the user wanted to be able to start a command shell and have it remain open waiting for commands to be sent to it from MATLAB. The way to do that from Windows is to use .NET assemblies as I linked to before.

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

カテゴリ

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