2

I have 2 scripts:

  1. python script
  2. matlab script

I need to run this two scripts in parallel (no output for both of them). I was thinknig to call to the python scirpt, from the matlab script.

I know it is possible to run python script from matlab like:

systemCommand='my_script.py'
system(systemCommand)

however in this way, the matlab script will wait to the return of the python script, and the rest of my matlab script will not be executed.

any ideas?

3
  • 1
    Have you tried appending an ampersand (&) to the end of your system command to send it to the background? ('my_script.py &') Commented Feb 20, 2016 at 14:42
  • I tried now and it works! thanks! Commented Feb 20, 2016 at 17:04
  • I have gone ahead and added it as a format answer. Glad it worked for you. Commented Feb 20, 2016 at 17:08

1 Answer 1

1

As mentioned near the end of MATLAB's system documentation in the "Tips" section, to run a system command in the background (on *nix), you can append an ampersand(&) to the end of your command to tell it to run in the background.

system('my_script.py &')

If you're on Windows, you'll want to use the following to prevent a command window from opening.

system('start /b my_script.py');
Sign up to request clarification or add additional context in comments.

7 Comments

Do you know how can I close the cmd that opens for the python script after I have finished using it?
At the end of your python script, do you have sys.exit(0)?
What Operating System?
Windows. did I understand you right? I have jest added the comad to the end of my code?
@TomE8 I just edited my question to include a Windows-specific answer. Try that one out.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.