Is there a way to asynchronously startup and run matlab commands from python using the matlab API for python without waiting for startup?
조회 수: 1 (최근 30일)
이전 댓글 표시
I am trying to call an optimization scheme from matlab using a python script. The goal is to retain control over my python script (to execute other commands) while matlab starts up and runs the optimization scheme in the background. The problem is that using the async option to start up matlab and to run matlab scripts/functions requires matlab to start in the background before any other python commands below the next matlab asynchronous command will execute. Is there a way to "stack" the asynchronous matlab startup with the other asynchronous matlab tasks so my python script can run through the rest of its code without waiting for the matlab start up? Python code attached for calling the sqrt matlab function asynchronously with sample output at the bottom. Using python 3.4.4 and matlab 2017a on Windows 10.
import matlab.engine as meng
# Start matlab asynchronously without loading JVM software to speed things up
eng = meng.start_matlab("-nojvm", async = True)
# Now call matlab to compute something asynchronously and print to see execution order
print('I am printed to screen when this python code is run')
ret1 = eng.result().sqrt(4.0, async = True)
print(ret1.result())
print('I am printed to screen after matlab starts up')
Output from python
# I am processed when this python code is run
# 2.0
# I am processed in python after matlab starts up
댓글 수: 1
esmitt
2020년 11월 3일
Hi, one question, did you solve this? I am facing with a similar situation! Thanks
답변 (0개)
참고 항목
카테고리
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!