フィルターのクリア

Can I give MATLAB commands in series from the OS command prompt?

7 ビュー (過去 30 日間)
HaveF
HaveF 2011 年 8 月 2 日
My question seems like this:
I want to keep only one MATLAB instance open, and then feed the m-file or "Matlab command" to Matlab from system command line or bat/bash file.
(I do NOT want to call m-file or "Matlab command" from Matlab command window for some reason)
  2 件のコメント
Doug Hull
Doug Hull 2011 年 8 月 2 日
What is the reason for wanting to do this? We may be able to recommend alternatives.
HaveF
HaveF 2011 年 8 月 3 日
Hi, Doug Hull, if the utilities by others(e.g.: system command, other language scripts) are very handy, I may use Matlab in this way.
In my case, I use Git for software version control, you may know, you can configure some hooks in Git, so, if I can pass command or m-file to Matlab, I can write hooks which will execute after you commit your code, such as unittest!
The workflow will be more fluency then.

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

採用された回答

Kaustubha Govind
Kaustubha Govind 2011 年 8 月 2 日
You can call into the MATLAB Engine or invoke the MATLAB COM Automation Server to control the creation of a single MATLAB process to execute multiple commands. Note that this involves some programming on your behalf in languages such as C/C++ which you may then compile into an executable and call from the system shell. The reason you cannot do this directly from the shell, is because shell commands - by principle - launch an executable and cannot call into runtime libraries directly (which is what executing individual MATLAB functions in an existing MATLAB session would entail).
  1 件のコメント
HaveF
HaveF 2011 年 8 月 3 日
Thanks for the reason you explained, Kaustubha Govind.
I tried COM interface before, but it seems not so convenience when I use it.
I use Python(pywin32) to handle the COM interface with Matlab, but the result return in Python instead of Matlab command window, and I can't find a solution to make the result appeared to Matlab command window.

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2011 年 8 月 2 日
If this is not MS Windows, you can create a pipe to a MATLAB session and send information back and forth. A difficulty with that is that MATLAB was not written with pipes in mind, and has no settings to adjust its buffering strategy or to force the output to be flushed (though you might be able to do explicit flushing with fflush()). Also, this would be effectively -nodisplay
If you are using MS Windows, then it has its own _pipe() call with slightly different semantics than the POSIX standard pipe() call. In theory, from XP SP2 and later, POSIX pipe() should work, but I have seen enough hints that you do not get "real" POSIX.1 that I would not trust that without hard testing.
To be clear, pipe() and _pipe() are at the OS level, not part of MATLAB.
  3 件のコメント
Kaustubha Govind
Kaustubha Govind 2011 年 8 月 3 日
The MATLAB Engine interface does use pipes on *nix Systems (COM on Windows). I think setting the visibility of the engine to true should also let you display results in the MATLAB window like you need.
HaveF
HaveF 2011 年 8 月 8 日
Thanks for the Tip;)

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

カテゴリ

Help Center および File ExchangeMATLAB Compiler についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by