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!