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

 Accepted Answer

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

2 Comments

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.

Sign in to comment.

More Answers (0)

Products

Release

R2018a

Community Treasure Hunt

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

Start Hunting!