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 件のコメント

Perrine Cristante
Perrine Cristante 2018 年 6 月 1 日
編集済み: Perrine Cristante 2018 年 6 月 1 日
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.
Fangjun Jiang
Fangjun Jiang 2018 年 6 月 1 日
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 件)

カテゴリ

製品

リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by