Groups | Blog | Home
all groups > dotnet interop > february 2008 >

dotnet interop : Type conversion C# and Matlab



hakansilver
2/22/2008 6:20:02 AM
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

stcheng@online.microsoft.com (
2/25/2008 2:51:46 AM
Hi Hakan,

For this MATLAB component, I'm not quite sure its actual functionality and
logic. However, I think you can check the Array declaration(used for COM
interop case). The following reference mentioned something about how to
declare Array in interop cases:

#Editing An Interop Assembly
http://msdn2.microsoft.com/en-us/library/8zbc969t(vs.71).aspx

Also, what's the expected value for that Array parameter in the MATLAB
function? Any dimension array?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.








--------------------
[quoted text, click to view]
AddThis Social Bookmark Button