Command Window output using Matlab engine in Python
23 views (last 30 days)
Show older comments
I want to be able to see the output printed in the Command Window in real-time while running a script using the Matlab engine in Python (I'm using the Spyder IDE). I've tried two approaches:
Approach 1:
I've started the Matlab engine with desktop using using the following commands:
eng = matlab.engine.start_matlab()
eng.desktop(nargout=0)
The desktop shows up, however all the output that should show in the Matlab Command Window when I run a Matlab script gets printed in the Spyder IDE console.
Approach 2:
Redirecting the standard output and error from Matlab to Python as described here: https://www.mathworks.com/help/matlab/matlab_external/redirect-standard-output-and-error-to-python.html
When using the approach from this Mathworks example, I have to wait for the Matlab script to finish running to see the output, so it doesn't work in real-time.
Does anyone know how I can make this work using either of these approaches or know of a different way of doing this? I am making a GUI using Pyside that can run some data processing with Matlab, but I want to see the progress printed by the Matlab script as it's running. With approach 2, I would just print the Matlab output to a QTextEdit in Pyside
1 Comment
Answers (1)
See Also
Categories
Find more on Call MATLAB from Python 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!