Via COM bridge of Matlab - getting Matlab structs

Hi
I am calling matlab from a C# application using the COM server. I use MLApp interface. From matlab method, what I return is a struct.
This struct looks like this
NumericResult = struct('results',doubleMatrix,'resultstatus', aCharArray,'header', header);
Further, header is a struct as following:
header = struct('name',someString,'datatype', somString,'description',someString);
I have been trying to get my results out as folowing:
Object resultMatrix1 = mlBridge.GetVariable("NumericResult.results", "base");
doing the above, i'd have expected to get 'results' which is a matlab matrix (a 2-dimensional array really). what i get is a rather cryptic exception. to fetch a character array, i tried using both GetVariable() and GetCharArray().
i tried following
Object obj1 = mlBridge.GetCharArray("NumericResult.resultstatus","base");
Object obj2 = mlBridge.GetVariable("NumericResult.resultstatus","base");
Both the statements give me an error. I am convinced the problem is due to my result object being a struct.
As a workaround I tried the following
mlBridge.Execute("Results = NumericResult.results;");
I can then fetch 'Results' using GetVariable() which worked but this is something I want to avoid. as more and more APIs are written in the team, this may not be a good idea.
Question - Through the COM bridge of Matlab - can I not get data using structure reference?

답변 (1개)

Kaustubha Govind
Kaustubha Govind 2011년 10월 4일

0 개 추천

I can't imagine that deferencing a structure element via GetCharArray or GetVariable is possible. You are effectively looking for a variable called 'NumericResult.resultstatus' which doesn't exist. You should probably try:
Object obj1 = mlBridge.Execute("NumericResult.resultstatus");

카테고리

도움말 센터File Exchange에서 COM Component Integration에 대해 자세히 알아보기

질문:

2011년 10월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by