calling matlab function from python- problem with starting engine and parallel pool
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello Everyone,
I'm calling a matlab function from the python but the problem is that matlab engine and parallel poll starts during every call which take some time and is significant.
Do you have any recommendation to have the matlab always in background so as to remove necessity for starting in every call?
code in python calling matlab:
eng = matlab.engine.start_matlab()
eng.Res_SS_2DToy_problem(nargout=0)
simul_obs = eng.workspace['Temperature_trend']
code in matlab:
myPool = gcp('nocreate');
if isempty(myPool)
myPool = parpool(50);
end
parfor i=1:size(rock.perm_all,2)
H{i}=ss(i);
end
Regards,
Behzad
0 comentarios
Respuestas (1)
Zhi Zeng
el 11 de Feb. de 2020
Hei, I am now encountering the same problem. I think I can give you an awkwark solution. That is: "interacting with Matlab using your file system by constantly checking file names ." For example, you want Matlab to calculate f(x). Then, the Python program saves a file named x.mat to a native folder and wait for the existence of another file named f_x. While Matlab is constantly checking whether there is a file named x.mat. If there is one, Matlab load the file and delete x.mat. After calculation, Matlab save the result as f_x.mat. On the other hand, Python program is constantly checking whether there is a file named f_x.mat. If there is one, it load the file and delete it.
0 comentarios
Ver también
Categorías
Más información sobre Call Python from MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!