How to execute an .m file from the command line in windows without opening a new matlab copy

26 次查看(过去 30 天)
The problem is, I want to execute a certain .m file from the command line. I know how to do already:
matlab -nosplash -r "run whathever.m"
Problem is, this opens a new instance of Matlab, I don't want that, I want it to simply use the already open instance of Matlab. Is there any way of doing that?
  3 个评论
Walter Roberson
Walter Roberson 2020-5-6
Using -nodesktop can prevent a new graphical interface from starting up, but this is not quite the same as using an existing MATLAB instance. In particular, if you used an existing MATLAB instance, you would have access to the state of that instance, such as the contents of the base workspace and global workspace. In theory one could even wish to run a command line that affected the graphics of an existing session.

请先登录,再进行评论。

采纳的回答

Kaustubha Govind
Kaustubha Govind 2013-3-5
I think you need to write code to call into MATLAB as a COM Server. You will also need to ensure that your currently running MATLAB session has been enabled to run as a COM Server. The instructions here should help with that.

更多回答(1 个)

Shizuka
Shizuka 2013-3-7
Thanks for the suggestion, but I couldn't get MATLAB to run as a COM server no matter how many times I tried, are there alternative ways to execute an .m file in an open instance?

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by