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

4 次查看(过去 30 天)
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;
}

回答(3 个)

Titus Edelhofer
Titus Edelhofer 2011-7-26
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

Walter Roberson
Walter Roberson 2011-7-26
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 2011-7-29
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

类别

Help CenterFile Exchange 中查找有关 .NET Client Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by