Matlab Coder cannot compile MEX function calls due to unknown type

8 ビュー (過去 30 日間)
William Ruppenthal
William Ruppenthal 2025 年 4 月 4 日
移動済み: Walter Roberson 2025 年 4 月 8 日
I am trying to use Matlab Coder to convert a moderately-sized existing sim tool to C++ to get a headstart vs re-writing it from scratch. However, I am running into an issue because my tool already uses MEX functions for coordinate transforms (all over the code), but whenever values from those functions are assigned, Coder will throw an error saying it cannot assign an unknown type to a double array. Is there any to get it to recognize that these functions are returning doubles? Worst case I guess I can just re-create the Matlab version of the transformations from scratch and go back and integrate the C++ source of the transforms later, but I would like to avoid that if possible.

回答 (1 件)

Ryan
Ryan 2025 年 4 月 7 日
移動済み: Walter Roberson 2025 年 4 月 8 日
Hi William,
To allow MATLAB Coder to determine the type of an assignment to an extinsic call, you can add a preceding declaration to that variable with a value of the type you need. For example,
coder.extrinsic("myext");
x = 0; % add this declaration
x = myext(); % myext returns double
use(x);
This happens since extrinsic functions return mxArrays, which are untyped without the added declaration. For more information, visit this help page: https://www.mathworks.com/help/coder/ug/use-matlab-engine-to-execute-a-function-call-in-generated-code.html#bq1h2z9-46
Please let me know if I can help you further!
  1 件のコメント
William Ruppenthal
William Ruppenthal 2025 年 4 月 8 日
移動済み: Walter Roberson 2025 年 4 月 8 日
Ah, thank you for the info!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by