- MATLAB Engine API for Python: If you’re comfortable with Python, you could use the MATLAB Engine API to connect to a running MATLAB session from Python. You can share the MATLAB Engine session by typing matlab.engine.shareEngine in the first MATLAB session. Then, from Python, you can connect to this shared session and execute commands or scripts.
- MATLAB Automation Server: On Windows, you can start MATLAB with the '-automation' flag which allows you to attach an engine program to a MATLAB session that is already running. This could potentially be used to interact with the first session from the second one.
- File-based Communication: A more straightforward approach might be to use file-based communication. The first session could write the required information to a file, and the second session could read from this file. This method is less elegant but can be easier to implement.
Open a 2nd Matlab session and read model-file open in the 1st session (programatically)
3 views (last 30 days)
Show older comments
I have a unique situation where I need to programatically open a 2nd session of Matlab and run a script. That is easy enough. However, I need this script to check for some info in the 1st session. For example, return the current path in the first session, return a list of all the Simulink models open in the first session, maybe even rename some signals in one of the models in session 1. This I have no idea how to do.
I've read a bit about UDP, doesn't look like that would work for my use-case. Any suggestions welcome. Thanks.
J
0 Comments
Answers (1)
Animesh
on 10 Jun 2024
Interacting between two MATLAB sessions can be quite complex, but there are a few approaches you might consider:
0 Comments
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!