필터 지우기
필터 지우기

Running a pvpython function in MATLAB

조회 수: 8 (최근 30일)
Amin Kassab-Bachi
Amin Kassab-Bachi 2021년 6월 14일
답변: Amin Kassab-Bachi 2021년 6월 14일
Hi all,
I'm trying to run a ParaView Python function using the "system" command but nothing is working. I can run scripts, but now I'm working with a function and failing to pass arguments to it.
I've been trying many variations of this command
system("'C:\Program Files\ParaView 5.8.0-Windows-Python3.7-msvc2015-64bit\bin\pvpython.exe C:\path\fileName.py arg1 arg2 arg3");
This particular syntax produced this error: The filename, directory name, or volume label syntax is incorrect.
system(['C:\Program Files\ParaView 5.8.0-Windows-Python3.7-msvc2015-64bit\bin\pvpython.exe C:\path\fileName.py ', arg1,' ', arg2,' ', arg3]) %Keeping in mind that the args are strings.
but I've been getting 'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
Any idea how to pass arguments to this function?
Thanks!

채택된 답변

Amin Kassab-Bachi
Amin Kassab-Bachi 2021년 6월 14일
SOLVED
Two Things had to change.
1- In the python script itself, I removed the "def" line. and declared the arguments as follows:
arg1= sys.argv[1]
arg2= sys.argv[2]
arg3= sys.argv[3]
Please note that sys.argv[0] is the file name.
2- Then, in MATLAB I declared the arguments
arg1= '"string1"'
arg2= '"string2"'
arg3= '"string3"'
3- Then executed the command
system(['"C:\Program Files\ParaView 5.8.0-Windows-Python3.7-msvc2015-64bit\bin\pvpython.exe" "C:\ path\fileName.py" ', arg1,' ', arg2,' ', arg3])
Note: The quotations and double quotations had to be used in this way. Otherwise, the system either did not recognize the paths or did not understand you have arguments, in which case I did not even get an error because matlab considered the script had run successfully, but the script returned no results.
Hope this is useful!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Python Package Integration에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by