possible to use the terminal command in matlab script?

Dear Experts
I am working with matlab2020b installed on linux.
I have another comand using terminal.
Is it possible to use the terminal command in script of matlab2020b.
It will save my time.
Thank you.

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 12 月 1 日

0 投票

You can use system(): https://www.mathworks.com/help/matlab/ref/system.html. However, note that it does not use the same $PATH variable as your default shell. You will need to use setenv() to add another directory to $PATH variable.

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 12 月 1 日

0 投票

You can use I/O redirection.
However, if you need two-way interaction then you need a pipe. There is a popen() in the File Exchange, but it is only for undirectional I/O . So you would have to do something like create a named pipe and read and write from it.
Note: every time you switch between reading and writing on a single file descriptor, you need to fseek(). Even if you tell fseek() to move 0 bytes relative to the current position, that is enough: the fseek() is needed to set up the I/O buffers properly.

カテゴリ

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

質問済み:

2020 年 12 月 1 日

コメント済み:

2020 年 12 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by