Pass multi dimensional byte array from C# to Matlab library using MWArray.

2 ビュー (過去 30 日間)
Hans Dohse
Hans Dohse 2024 年 2 月 12 日
回答済み: Aditya 2024 年 2 月 22 日
I have a C# array
byte[,,] r = new byte[2, 3, 4];
I have a matlab function which takes in a 3D byte array.
How do I use MWArray to transfer the data?

回答 (1 件)

Aditya
Aditya 2024 年 2 月 22 日
Hi Hans,
I understand that you have a 3D byte array in C# that you need to pass to a MATLAB function, which expects a 3D byte array as input, using the “MWArray interface provided by the MATLAB Compiler SDK.
To achieve this, you can follow these points:
  1. Create your 3D byte array in C#.
  2. Convert the C# byte array to an MWNumericArray, which is a specialized type of MWArray designed for numeric data.
  3. Invoke the MATLAB function with the MWNumericArray as an argument.
  4. The function's return value will be stored in an MWArray object, which you can then use in your C# application.
MWArray is the base class for different array types in MATLAB, and MWNumericArray is a derived class that specifically handles numeric data, making it suitable for transferring numeric arrays like your byte array.
For further guidance on data conversion and handling different data types when interfacing between .NET and MATLAB, you can utilize the below MATLAB resources:
These resources provide valuable information on how to effectively manage data conversion, ensuring accurate communication between your C# application and MATLAB functions.
Hope this helps!

カテゴリ

Help Center および File ExchangeDeploy to .NET Applications Using MWArray API についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by