Call MATLAB Functions Asynchronously from Python
This example shows how to call the MATLAB®
asynchronously from Python® and retrieve the square root later.
The engine calls MATLAB functions synchronously by default. Control returns to Python only when the MATLAB function finishes. But the engine also can call functions asynchronously. Control immediately returns to Python while MATLAB is still executing the function. The engine stores the result in a Python variable that can be inspected after the function finishes.
background argument to call a MATLAB function asynchronously.
import matlab.engine eng = matlab.engine.start_matlab() future = eng.sqrt(4.0,background=True) ret = future.result() print(ret)
done method to check if an
asynchronous call finished.
tf = future.done() print(tf)
To stop execution of the function before it finishes, call