This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Pass Complex Data to MATLAB from C# Client

This example creates complex data in the client C# program and passes it to MATLAB®. The matrix consists of a vector of real values in variable pr and of imaginary values in pi. The example reads the matrix back into the C# program.

The reference to the MATLAB Type Library for C# is:

MLApp.MLApp matlab = new MLApp.MLApp();

From your C# client program, add a reference to your project to the MATLAB COM object. For example, in Microsoft® Visual Studio®, open your project. From the Project menu, select Add Reference. Select the COM tab in the Add Reference dialog box. Select the MATLAB application.

Here is the complete example:

using System;
namespace ConsoleApplication4
class Class1
static void Main(string[] args)
MLApp.MLApp matlab = new MLApp.MLApp(); 

System.Array pr = new double[4];

System.Array pi = new double[4];

matlab.PutFullMatrix("a", "base", pr, pi);

System.Array prresult = new double[4];
System.Array piresult = new double[4];

matlab.GetFullMatrix("a", "base", ref prresult, ref piresult);

See Also


Was this topic helpful?