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

 채택된 답변

Fangjun Jiang
Fangjun Jiang 2018년 6월 1일

0 개 추천

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

댓글 수: 2

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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

제품

릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by