running python script in matlab
조회 수: 6 (최근 30일)
이전 댓글 표시
Hi, I have one python script and i want to execute that in matlab.I tried with system in matlab. s=system('python trail.py 3') while excuting this command i'm getting a error like below. 'python' is not recognized as an internal or external command, operable program or batch file. Please can anybody help me in fixing this error. Thanks in advance
Regards Vasavi
댓글 수: 0
채택된 답변
Walter Roberson
2012년 6월 22일
Either python is not installed in your system or it is not on your MS Windows PATH as known to MATLAB.
Inside MATLAB, command
getenv('PATH')
and see what it shows.
Note: python is not automatically installed as part of MATLAB. perl is, though, installed as part of MATLAB.
댓글 수: 7
Sameer Khan
2013년 7월 15일
편집: Sameer Khan
2013년 7월 15일
sai vasavi: can you pleasse tell me how to run a mcros file with a .py extension in matlab? i want to get a .rpt file from abaqus simulation automatically for that i prepared a macros file with .py extension. I am new to abaqus and need help. or any other way to get the output values of displacements at a node for all time.?
Jerry Olup
2020년 7월 29일
Found that you can get results back from python invoked from matlab by using [s,r] return values for system call where the strings python emits can be captured and parsed. Might be good to use files holding larger amounts of data with names printed for matlab to pick up and read.
A simple test I did was to write a squaring function and pass args:
>> arg1 = "1 2 3 4 5";
>> [s,r] = system(sprintf('python pysqr.py %s', arg1));
>> r
r =
'argument 1: 1
arg: 1 - sqr: 1
argument 2: 2
arg: 2 - sqr: 4
argument 3: 3
arg: 3 - sqr: 9
argument 4: 4
arg: 4 - sqr: 16
argument 5: 5
arg: 5 - sqr: 25
'
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!