필터 지우기
필터 지우기

Access MATLAB function in own function via python

조회 수: 2 (최근 30일)
Tobias Nagel
Tobias Nagel 2018년 6월 25일
답변: Helper 2018년 6월 28일
I want to access a MATLAB-function, that is used inside my own function via python. Therefore I use the python-package "matlab.engine". Including a MATLAB-function according to the documentation works fine. But supposing my MATLAB-function looks like this:
function y = test_function(input)
y = isprime(input)
end
and I want to access it via the following python script:
import matlab.engine
eng = matlab.engine.start_matlab()
a = eng.test_function(37.0, nargout=0, async=False)
print(a)
Then I get the following error:
Undefined function 'isprime' for input arguments of type 'double'

채택된 답변

Helper
Helper 2018년 6월 28일
Please make sure all the functions, "test_function" and "isprime" are in MATLAB search path or the current folder. The MATLAB engine we launched inside Python will have the default MATLAB search path. So if the function "isprime" is not in the search path or the current folder, then MATLAB cannot recognize it.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Call MATLAB from Python에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by