Borrar filtros
Borrar filtros

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

5 visualizaciones (últimos 30 días)
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;
}

Respuestas (3)

Titus Edelhofer
Titus Edelhofer el 26 de Jul. de 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 comentario
Titus Edelhofer
Titus Edelhofer el 26 de Jul. de 2011
Forgot to mention: this is while assuming you are using Builder NE for compiling the MATLAB code...?

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 26 de Jul. de 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 el 29 de Jul. de 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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by