필터 지우기
필터 지우기

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

조회 수: 5 (최근 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
  댓글 수: 1
Titus Edelhofer
Titus Edelhofer 2011년 7월 26일
Forgot to mention: this is while assuming you are using Builder NE for compiling the MATLAB code...?

댓글을 달려면 로그인하십시오.


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