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?

Answers (1)

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");

Categories

Asked:

on 4 Oct 2011

Community Treasure Hunt

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

Start Hunting!