110,537
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MathWorks.MATLAB.NET.Arrays;
using MathWorks.MATLAB.NET.Utility;
namespace myapp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
test.demo output = new test.demo(); //将demo类实例化
MWArray a = 2; //建立MWArray类作为以便matlab能够识别
MWArray b = 3;
MWArray[] x = output.myadd2(2, a, b); //”2”为输入的个数
MWNumericArray y = (MWNumericArray)x[0];
MWNumericArray z = (MWNumericArray)x[1]; //提取输出y、z
double[,] y1 = (double[,])y.ToArray(MWArrayComponent.Real);
double[,] z1 = (double[,])z.ToArray(MWArrayComponent.Real);
//将y、z转换为C#数组
double y2 = y1[0, 0];
double z2 = z1[0, 0];
textBox1.Text = y2.ToString();
textBox2.Text = z2.ToString();
}
}
}