How can I return a MATLAB object into a MWArray using MATLAB Builder for .Net?

How can I return a MATLAB object into a MWArray using MATLAB Builder for .Net?
c#
MWCellArray cellout = null;
MWNumericArray X = new MWNumericArray(new Int64());
MWNumericArray Y = new MWNumericArray(new Int64());
MWNumericArray Z = new MWNumericArray(new Int64());
try
{
Class1 obj = new Class1();
cellout = (MWCellArray)obj.FDH(X, Y, Z);
MWNumericArray item1 = (MWNumericArray)cellout[1];
MWNumericArray item2 = (MWNumericArray)cellout[2];
MWCharArray item3 = (MWCharArray)cellout[3];
Console.WriteLine("item1 is {0}", item1);
Console.WriteLine("item2 is {0}", item2);
Console.WriteLine("item3 is {0}", item3);
double[,] native1 = (double[,])item1.ToArray(MWArrayComponent.Real);
double[,] native2 = (double[,])item2.ToArray(MWArrayComponent.Real);
char[,] native3 = (char[,])item3.ToArray();
// Wait for user to exit application
Console.ReadLine();
}
catch (Exception exception)
{
Console.WriteLine("Error: {0}", exception);
}
error System.InvalidCastExcepiton: 'Mathwroks.MatLAB.NET.Arrays
cellout = (MWCellArray)obj.FDH(X, Y, Z); => X Y Z I think this is problem which is casting...

Réponses (0)

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by