Command Window output using Matlab engine in Python
19 次查看(过去 30 天)
显示 更早的评论
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 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Call MATLAB from Python 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!