Trying to run MATLAB from Python
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I'm trying to call a MATLAB script from Python, I've been using this code:
import matlab.engine
eng = matlab.engine.start_matlab()
eng.myScript(nargout=0)
I initiated this code after starting a MATLAB shared session using this in MATLAB:
matlab.engine.shareEngine
For some reason it doesn't work, I'm not getting any output and when I'm trying to retrieve variables from the workspace it gives me this error:
>> eng.workspace['T2']
Traceback (most recent call last):
File "<ipython-input-197-b0020f6fe85d>", line 1, in <module>
eng.workspace['T2']
File "C:\Anaconda3\lib\site-packages\matlab\engine\matlabengine.py", line 120, in __getitem__
future = _method(attr)
File "C:\Anaconda3\lib\site-packages\matlab\engine\matlabengine.py", line 71, in __call__
_stderr, feval=True).result()
File "C:\Anaconda3\lib\site-packages\matlab\engine\futureresult.py", line 67, in result
return self.__future.result(timeout)
File "C:\Anaconda3\lib\site-packages\matlab\engine\fevalfuture.py", line 82, in result
self._result = pythonengine.getFEvalResult(self._future,self._nargout, None, out=self._out, err=self._err)
MatlabExecutionError:
File C:\Program Files\MATLAB\R2020a\toolbox\matlab\external\engines\engine_api\+matlab\+internal\+engine\getVariable.m, line 27, in getVariable
Undefined variable 'T2'.
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Python Package Integration dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!