Type conversion C# and Matlab

H

hakansilver

Dear all,

We try to access a third party Matlab dll (which was created using Matlab
COM Builder) from C#. It works fine when using strings and one-dimensional
arrays but fails with two-dimensional arrays. We give our example of the code
below:

static void TestBasicStat()
{

MatlabCOM pda = new MatlabCOM();
Object mError = new int();
Array TempTagValues = new double[10, 20];
Object gaTagValues = new Object(); // This is the result from
Matlab. It should be a 2-dim array
pda.basicstatistics(2, ref gaTagValues, ref mError,
TempTagValues);
}

An exception is thrown from the Matlab code when Matlab tries to access the
two-dimensional array.

Does anyone know if a double array is the correct conversion to a Matlab
matrix?

Also, please let me know if this is not the right newsgroup to post for this
question.

Thank you in advance!

Best regards

Hakan
 
K

Kalpesh

Hakan,

I have not worked with matlab & using com from c#.
However, I have a suggestion

What does the intellisense show when you pda.basicstatistics(
Also, you could change
Array TempTagValues = new double[10, 20];
to
double[,] TempTagValues = new double[10, 20];

HTH
Kalpesh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top