How to ouput .NET object instead of "MWStructArray" in MATLAB Compiler SDK?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 23 Ott 2023
Modificato: MathWorks Support Team
il 20 Giu 2025
I am trying to create a standalone executable using MATLAB Compiler SDK, where I want to marshal MATLAB structs in C# using .NET structs and classes. I am using the following example as a reference:
I have the following questions:
1) My MATLAB function outputs a "MWStructArray", while I would expect a .NET "Student" object like in the example. How can I return a .NET "Student" object directly from the MATLAB function call?
2) Is there a way to directly unmarshal the "MWStructArray" or "MWCellArray" without having to convert field by field?
Risposta accettata
MathWorks Support Team
il 20 Giu 2025
Modificato: MathWorks Support Team
il 20 Giu 2025
You can find the answers below:
1) It is not possible with the native MWArray API using "SortScoresNative.dll". If you use the non-native API from "SortScores.dll", you can return .NET "Student" object inside the MATLAB function. An "MWObjectArray", named for example "obj", will be yielded on the .NET side, and you can cast "obj.Object" to "Student" using "(Student[])obj.Object".
2) It is not possible with the native "MWArray API" using "SortScoresNative.dll", and analogously for "MWCellArray". If you use the non-native API from "SortScores.dll", you may use the static method called "ConvertToNativeTypes" in the base "MWArray" class, as reported in the following link:
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Deploy to .NET Applications Using MWArray API in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!