How to define the <SHAPE> of an array with variable size in a c++ clib function?

4 ビュー (過去 30 日間)
JoRo
JoRo 2023 年 3 月 6 日
回答済み: JoRo 2023 年 3 月 7 日
Hi,
I am trying to build a c++ clib.
After running:
clibgen.generateLibraryDefinition(...)
I get a definemylib.mlx.
There I have to define the shape of the function input:
defineArgument(mycppfunctionDefinition, "myarray", "clib.array.mylib.Double", "input", <SHAPE>)
In my c++ file, the corresponding function is defined as:
void mycppfunction(double myarray[]);
Because the size of myarray changes in matlab, I do not know how to define the <SHAPE>.
but I did not find an answer, if the size is unknown / changing...
Can anyone give me a tip, how to solve this problem?
Best regards.

採用された回答

JoRo
JoRo 2023 年 3 月 7 日
In case anyone faces the same issue: I solved the problem.
I had to redefine the c++ function to:
void mycppfunction(double myarray[], size_t len);
Then I had to add "len" to the definemylib.mlx file to:
defineArgument(mycppfunctionDefinition, "myarray", "clib.array.mylib.Double", "input", "len").
Now it works.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by