how to run much phyton script with matlab

조회 수: 1 (최근 30일)
giulia cervelli
giulia cervelli 2020년 6월 24일
답변: Aditya Gupta 2020년 6월 24일
hei matlab users,
I need to run much phyton scripts to request some data from ECMWF database. I have write this scripts but when i run the first of them matlab waits its end while I want run all my scripts togheter: I need it because every requestes have to be elaborated and I obtain the data after much hours/days.
In this moment I have a crude solution:
% 1) run this line
k=0;
name_of_my_script=[name1, name2, name3, etc];
%%
%2) run this section
k=k+1;
system(['python' name_of_my_script(k) '.py'])
%3) Ctrl+C in the command window
%4) run the second section
%5) Ctrl+C in the command window
%6) run the second section
%) etc.

답변 (1개)

Aditya Gupta
Aditya Gupta 2020년 6월 24일
You can alternatively create a temporary bash script using file operations (and - ofcourse - loops) of the following format:
python script1.py &
python script2.py &
python script3.py &
python script4.py &
That's the entire script. It will run the four Python scripts at the same time. The "&" shell operator tells each process to go into the background
Now use the system command to run this script inside the matlab script.
Dont forget to delete the temporary file.

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by