フィルターのクリア

MATLAB Coder datatypes in C#

3 ビュー (過去 30 日間)
Philipp
Philipp 2024 年 2 月 7 日
回答済み: Sumit Ghosh 2024 年 2 月 15 日
Hello,
is there a guide or a template on how to specify the custum data types (which produces the Coder like rtString or emxArray_char_T) in C#? As you can't just include the h-file. I'm trying to include a DLL (written in MATLAB) in C#.
Thanks in advance!
  1 件のコメント
Sumit Ghosh
Sumit Ghosh 2024 年 2 月 12 日
You can try to avoid generation of emxArray types in the DLL by not relying on variable size arrays. This will result in generation primitive types like double arrays, which you can interface with C#.
To avoid using variable-size arrays, you can change the config settings related to Dynamic Memory Allocation. for this, you can use coder.EmbeddedCodeConfig
Option 1: Set the DynamicMemoryAllocation property to Off to disable variable-size arrays for all arrays in your code
Option 2: By default, DynamicMemoryAllocation is set to Threshold, and you can adjust the threhold value to something within which your array will not use variable-size. To do this, you can use the property DynamicMemoryAllocationThreshold (default vaue is 65536).
You can look at examples in https://www.mathworks.com/help/coder/ug/use-c-arrays-in-the-generated-function-interfaces.html to see how to generate the C function interface using primitive types instead of emxArrays.
To avoid generation rtString type, you can specify your string inputs during code generation as a character vector.

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

回答 (1 件)

Sumit Ghosh
Sumit Ghosh 2024 年 2 月 15 日
You can try to avoid generation of emxArray types in the DLL by not relying on variable size arrays. This will result in generation primitive types like double arrays, which you can interface with C#.
To avoid using variable-size arrays, you can change the config settings related to Dynamic Memory Allocation. for this, you can use coder.EmbeddedCodeConfig
Option 1: Set the DynamicMemoryAllocation property to Off to disable variable-size arrays for all arrays in your code
Option 2: By default, DynamicMemoryAllocation is set to Threshold, and you can adjust the threhold value to something within which your array will not use variable-size. To do this, you can use the property DynamicMemoryAllocationThreshold (default vaue is 65536).
You can look at examples in https://www.mathworks.com/help/coder/ug/use-c-arrays-in-the-generated-function-interfaces.html to see how to generate the C function interface using primitive types instead of emxArrays.
To avoid generation rtString type, you can specify your string inputs during code generation as a character vector.

カテゴリ

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

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by