How to run .m file in python
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (1)
David Gonzalez
el 28 de Mzo. de 2019
0 votos
How can I do this if the script is in another folder?
Thanks!
3 comentarios
Wasabi Lee
el 25 de Abr. de 2019
You should just add the location of the file to path.
addpath('matlab/myfiles','-end')
Yihui Quek
el 22 de Jul. de 2019
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
el 10 de Mzo. de 2020
Editada: Huang Chi-En
el 10 de Mzo. de 2020
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 ~~
Categorías
Más información sobre Call Python from MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!