How to input an argument in an Exit Shell command ?

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

 Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 1 de Jun. de 2018

0 votos

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

2 comentarios

Perrine Cristante
Perrine Cristante el 1 de Jun. de 2018
Editada: Perrine Cristante el 1 de Jun. de 2018
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Versión

R2018a

Preguntada:

el 1 de Jun. de 2018

Comentada:

el 1 de Jun. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by