金华网站建设团队,网站开发教程免费,需要一个网站,官方网站下载qq最新版matlab打包dll
1、matlab示例程序#xff1a;
function untitled4(x)z peaks(x);figuresurf(z)
end
2、输入deploytool打包matlab程序#xff0c;具体如下#xff1a; 3、拷贝
打包成功后#xff0c;将生成for_redistribution_files_only文件夹中的dll文件拷贝到C#程序…matlab打包dll
1、matlab示例程序
function untitled4(x)z peaks(x);figuresurf(z)
end
2、输入deploytool打包matlab程序具体如下 3、拷贝
打包成功后将生成for_redistribution_files_only文件夹中的dll文件拷贝到C#程序lib文件夹下若没有新创建一个。 错误解决 解决方法将matlab程序改写成一个方法。
C#调用dll
1、添加引用 MWArray.dll在matlab安装目录..\matlab\toolbox\dotnetbuilder\bin\win64\v4.0下
2、导入包
using untitled4;
using MathWorks.MATLAB.NET.Arrays;
3、添加button点击事件
private void Button1_Click(object sender, EventArgs e)
{untitled4.Class1 p3 new untitled4.Class1();p3.untitled4((MWArray)25);
}
完整示例代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using untitled4;
using MathWorks.MATLAB.NET.Arrays;namespace test1
{public partial class Form1 : Form{public Form1(){InitializeComponent();}private void Form1_Load(object sender, EventArgs e){}private void Button1_Click(object sender, EventArgs e){untitled4.Class1 p3 new untitled4.Class1();p3.untitled4((MWArray)25);}}
}错误解决1 解决方法debug平台改为×64位 错误解决2: 解决方法matlab程序返回一个数而C#代码接收的是MWArray数据。
p3.untitled4((MWArray)25); 运行结果