Hi everybody,
I need to execute a Python script taking an argument from a Matlab script. I already tried this in my MatLab script :
ECG = input('Nom de fichier : ','s')
!C:\Users\Philippe\Anaconda2\python.exe Test.py &
ECG
EGC being the argument I need to run the Python script, but it doesn't work. Any idea on how I could do this ?
Thanks

 Réponse acceptée

Fangjun Jiang
Fangjun Jiang le 1 Juin 2018

0 votes

try this
system(['C:\Users\Philippe\Anaconda2\python.exe Test.py & ', ECG])

2 commentaires

I tried this, but it does not work. It results in an error :
Traceback (most recent call last):
File "Test.py", line 4, in <module>
filename = str(sys.argv[1])
IndexError: list index out of range
I think he does not recognize the 'ECG' as a part of the command.
try typing in the command yourself first to see what happens.
system('c:\users\.....')
Then try ['C:\Users\Philippe\Anaconda2\python.exe Test.py & ', ECG] to see if it returns the exact string as you would type it yourself. It it is, then the error is caused by something else.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Produits

Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by