how to pass a complex structure to a matlab routine called by C# application?
4 views (last 30 days)
Show older comments
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;
}
0 Comments
Answers (3)
Titus Edelhofer
on 26 Jul 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 Comment
Titus Edelhofer
on 26 Jul 2011
Forgot to mention: this is while assuming you are using Builder NE for compiling the MATLAB code...?
Walter Roberson
on 26 Jul 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.
0 Comments
Titus Edelhofer
on 29 Jul 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
0 Comments
See Also
Categories
Find more on .NET Client Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!