Issue running compiled Matlab function script in Python

6 ビュー (過去 30 日間)
Pri_Comet
Pri_Comet 2021 年 5 月 26 日
回答済み: decai lin 2023 年 9 月 11 日
I'm trying to run a compiled Matlab function in Python based on instructions from here: https://www.mathworks.com/help/compiler_sdk/gs/create-a-python-application-with-matlab-code.html
I compiled my function
function yy = TestFn
a = 7;
b = 4;
yy = a + b;
end
using the libraryCompiler app. The compiled package was named "TestFnCompiled2".
I then used a python script
import TestFnCompiled2
foo = TestFnCompiled2.initialize()
y = foo.TestFn
print(y)
foo.terminate()
Instead of print(y) returning the value '11', I get the following:
<matlab_pysdk.runtime.deployablefunc.DeployableFunc object at 0x0000011009378860>
Couldn't find any references to this online. Any help would be appreciated.

回答 (1 件)

decai lin
decai lin 2023 年 9 月 11 日
import TestFnCompiled2
foo = TestFnCompiled2.initialize()
y = foo.TestFn() #invoke func,with brackets
print(y)
foo.terminate()

カテゴリ

Help Center および File ExchangePython Package Integration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by