c#调用MATLAB实现方法报告
目的:在VS里新建一个窗体界面,通过其中一个按钮来调用在MATLAB里编写的函数。
工具: MATLAB2016a
VS 2010
1.实现思路:首先对MATLAB进行编译器设置,通过deploytool工具将MATLAB中的.m文件生成.dll文件,在VS“引用”添加两个.dll文件,写入代码调用。
2.实现效果展示:
MATLAB代码
function test
f=250;
ts=0.4502/f;
T=ts;
number=100;
t=-number/2:1:number/2;
a=(1-2*(pi*f*t*T).^2).*exp(-(pi*f*t*T).^2);
plot(t,a);
c#代码
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;
namespace WindowsFormsApplication1
{
public partial class Form1 : F