Hi,
I'm planning to interact with MATLAB from Python (Pytorch) to do some machine learning. To get my hands on I'm testing it on a toy case (Lorenz attractor) but I'm facing a weird behavior.
I have one script in Python and one in MATLAB, both doing exactly the same thing : calling RK4/Lorenz.
In MATLAB everything runs smoothly (obviously) :
Elapsed time is 0.000041 seconds.
Elapsed time is 0.000043 seconds.
Elapsed time is 0.000060 seconds.
Elapsed time is 0.000071 seconds.
Elapsed time is 0.000045 seconds.
Now in Python, if I look at the execution time from MATLAB only (inside the function) it's ok :
Elapsed time is 0.000054 seconds.
Elapsed time is 0.000096 seconds.
Elapsed time is 0.000049 seconds.
Elapsed time is 0.000060 seconds.
Elapsed time is 0.000054 seconds.
The problem is if I look at the execution time of the MATLAB function from the Python script this time :
Python call 0.013752460479736328
Python call 0.18750524520874023
Python call 0.005811214447021484
Python call 0.04061627388000488
Python call 0.006798982620239258
Python call 0.8868112564086914
Python call 0.0055887699127197266
Python call 0.16828298568725586
Python call 0.003731250762939453
Looks like it's getting randomly slowed down/stucked. Here is the Python code :
eng = matlab.engine.start_matlab()
n_step = int(duration // timestep)
data = eng.zeros(n_step, 3)
for i in range(n_step - 1):
data[i + 1] = eng.RK4(data[i], 10.0, 8/3, 28.0, timestep)[0]
Am I doing something wrong or is it a known issue of the engine?
Thank you,
Thibaut