how to run much phyton script with matlab

1 view (last 30 days)
giulia cervelli
giulia cervelli on 24 Jun 2020
Answered: Aditya Gupta on 24 Jun 2020
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.

Answers (1)

Aditya Gupta
Aditya Gupta on 24 Jun 2020
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.

Community Treasure Hunt

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

Start Hunting!