Calling mex Function from Python extension
22 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to write a Python extension program to call a MATLAB mex function. What I want to do is to have my program directly call the function mexFunction(...) with my own mxArray parameters, etc.
When I run the program in Python I get a DLL load error. After some experimenting I found that if I comment out the include statement for mex.h the program loads fine, but as soon as I include mex.h I get the DLL load error again.
My theory is that there is a DLL conflict because the program as been declared to be both a Python DLL and a MATLAB DLL and the system gets confused. I tried going into the mex.h file and commenting out the DLL_EXPORT command hoping I could trick it, but that didn't help. So now I'm thinking that maybe it is still getting declared as a DLL in the MATLAB lib files, but that is just a guess.
The bottom line is this. I basically want to be able to call a mex function from my own program similar to how MATLAB would call the function, passing in the mxArray variables and other parameters. I assume they are doing something like a call to LoadLibrary followed by GetProcAddress. How can I do something similar without it thinking that this is a DLL?
Thank you.
0 Kommentare
Antworten (1)
Bo Li
am 22 Sep. 2016
How do you want to invoke this MEX file? From inside MATLAB or in Python? You can use mxArray in Python without using MEX. Or you can use Python Interface to invoke the Python extension directly from MATLAB:
2 Kommentare
Bo Li
am 23 Sep. 2016
Maybe you can add the matlabroot/bin/win64 folder into the system PATH and see how it works.
Siehe auch
Kategorien
Mehr zu Call Python from MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!