Call MATLAB Functions from Python
Call MATLAB Functions from Python
(OP)
Hello everyone,
I am currently working on a project in which I am doing a data analysis with Python. The data that I use as a basis comes from a Matlab script that was not written by me. My approach for the connection is based on the link below.
https://de.mathworks.com/help/matlab/matlab_extern...
But when I try to run import matlab.engine in my Jupyter notebook, it shows the following error message:
That surprises me because I have actually already installed the Matlab package several times. I use Python 3.7 and my Matlab version is 2021a (with license).
I hope that someone can help me. I am also grateful for alternative approaches.
Best regards Philipp
I am currently working on a project in which I am doing a data analysis with Python. The data that I use as a basis comes from a Matlab script that was not written by me. My approach for the connection is based on the link below.
https://de.mathworks.com/help/matlab/matlab_extern...
But when I try to run import matlab.engine in my Jupyter notebook, it shows the following error message:
ModuleNotFoundError: No module named 'matlab.engine'; 'matlab' is not a package
That surprises me because I have actually already installed the Matlab package several times. I use Python 3.7 and my Matlab version is 2021a (with license).
I hope that someone can help me. I am also grateful for alternative approaches.
Best regards Philipp
RE: Call MATLAB Functions from Python
Dan - Owner
http://www.Hi-TecDesigns.com
RE: Call MATLAB Functions from Python
Are the data from the matlab script just a static set or are you trying to analyze them continuously as they are produced?
RE: Call MATLAB Functions from Python
matlab.engine.start_matlab
Start MATLAB Engine for Python
Syntax
eng = matlab.engine.start_matlab()example
eng = matlab.engine.start_matlab(option)
I'm not quite sure why this step is so remarkable.
Cheers
Greg Locock
New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies http://eng-tips.com/market.cfm?
RE: Call MATLAB Functions from Python
@MacGyverS2000:
I followed the instructions in the following link. I therefore believe that engine should actually be part of the Matlab package (similar to matplotlib.pyplot where matplotlib only has to be installed). I am not sure though. Do you have any ideas how to install it otherwise?
https://de.mathworks.com/help/matlab/matlab_extern...
@onatirec:
Indeed, it would work that way. Since the analysis should ultimately be integrated into a running system, it would certainly be possible, but in the end it would be more of a work-around. I therefore see this as a last resort.
@GregLocock:
Unfortunately, the problem lies earlier. I cannot call an expression with matlab.engine without getting an error message. So I believe the problem is with the installation. I just have no idea where.
Thanks alot.
Philipp
RE: Call MATLAB Functions from Python
Just one last question. Could that be the reason or am I missing something?
RE: Call MATLAB Functions from Python
You can add the path to the install of matlab.engine temporarily at the start of your script. Check here for details.
https://engineervsheep.com