How to run .m file in python
이전 댓글 표시
I have a .m code what I want to run in python. Is it any easy way? 1. this code is not a function. 2. don't want to show the matlab window.
Best Regards
Xinfeng
채택된 답변
추가 답변 (1개)
David Gonzalez
2019년 3월 28일
0 개 추천
How can I do this if the script is in another folder?
Thanks!
댓글 수: 3
Wasabi Lee
2019년 4월 25일
You should just add the location of the file to path.
addpath('matlab/myfiles','-end')
Yihui Quek
2019년 7월 22일
I think the OP means, 'what should I add to my Python script if I want it to run a matlab script in a different folder?' Your command is a Matlab command, which doesn't help if the Matlab script can't even be found by Python.
Huang Chi-En
2020년 3월 10일
편집: Huang Chi-En
2020년 3월 10일
The classical python function :
# python..
import sys
positionOfPath = 1
sys.path.insert( positionOfPath, 'your matlab path' )
# end of python
may help python find the path to access the matlab script ~~
카테고리
도움말 센터 및 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!