Effacer les filtres
Effacer les filtres

how to pass a complex structure to a matlab routine called by C# application?

5 vues (au cours des 30 derniers jours)
alorenzom
alorenzom le 26 Juil 2011
Can I for example pass into a matlab routine called by C# application, a structure like this:
struct Struct2
{
int value5;
}
struct Struct1
{
int value1;
int value2;
Struct2 value3;
Struct2[] value4;
}

Réponses (3)

Titus Edelhofer
Titus Edelhofer le 26 Juil 2011
Hi,
yes, you can. You build up the MATLAB structure using the MWStructArray class, something like
String[] val5 = {"value5"};
MWStructArray value3 = new MWStructArray(1, 1, val5);
// fill value3
MWStructArray value4 = new MWStructArray(1, 5, val5);
// fill value4
String[] s1 = {"value1", "value2", "value3", "value4"};
MWStructArray Struct1 = new MWStructArray(1, 1, s1);
// fill Struct1
Take a look at matlab_root\toolbox\dotnetbuilder\Examples\VS8\NET\PhoneBookExample\PhoneBookCSApp\PhoneBookApp.cs for an example (or the doc at
web([docroot '/toolbox/dotnetbuilder/ug/brl3b0g-1.html'])
Titus
  1 commentaire
Titus Edelhofer
Titus Edelhofer le 26 Juil 2011
Forgot to mention: this is while assuming you are using Builder NE for compiling the MATLAB code...?

Connectez-vous pour commenter.


Walter Roberson
Walter Roberson le 26 Juil 2011
I do not know the answer for C# . If it were C, then the theoretical answer would be NO, but the practical answer would be "Yes, as long as you do not want to access the contents of the structure and just want to pass its address".
MATLAB structures are quite different internally than C or C++ or C# structures.

Titus Edelhofer
Titus Edelhofer le 29 Juil 2011
Hi,
there is an interesting blog article which shows recent advances in Builder NE that make this easier then what I wrote above: http://blogs.mathworks.com/loren/?s_cid=global_nav
Titus

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by