MATLAB Answers

How call a matlab function in the c compiled library in python?

조회 수: 8(최근 30일)
Seyoung Kim
Seyoung Kim 27 Nov 2018
Edited: Jim David 3 Dec 2018
Hello
I'd like to write the code calling the matlab function from shared c library.
But when I call the function in the python using ctype library, I immediately got an error by the segmentation fault.
I don't know what's wrong with it and I'm not even know if it's possible or not.
Do you have any example code?
What I'm trying to do is like this code below.
import ctypes
cdll = ctypes.cdll.LoadLibrary("myLib.so")
if not cdll.myLibInitialize() :
print "** Error : library is not initiallized ..."
exit
else :
freturn = ctypes.c_char_p("temp.mat")
ptr_freturn = ctypes.pointer(freturn)
arg = ctypes.c_int(9)
ptr_arg= ctypes.pointer(arg)
cdll.mlfTest_func(1, ptr_freturn , ptr_arg)

  댓글 수: 0

로그인 to comment.

답변 수 (1)

Jim David
Jim David 3 Dec 2018
Jim David 님이 편집함. 3 Dec 2018
Hello Seyoung
In order to use a MATLAB function in Python, MathWorks offers Python Package integration through the MATLAB Compiler SDK the documentation for which can be found here:
Hope this helps

  댓글 수: 0

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.

태그


Translated by