您当前的位置:matlab资源网文章中心资料 → 文章内容

.NET2008 调用MATLAB

作者:chenhai20010201  来源:转载  发布时间:2008-7-31 8:57:36

1。在.net项目中点:add reference,在打开的页面,选择COM|Matlab Application(version 7.0) Type Library等

2。

Subject:

How do I invoke MATLAB as an Automation server from C#?

Problem Description:

How do I invoke MATLAB as an Automation server from C#?

Solution:

The following simple example illustrates how to invoke MATLAB as an Automation server from C#.

 

using System;

using System.Reflection;

namespace ConsoleApplication4

{

class Class1

{

[STAThread]

         static void Main(string[] args)
         {
             //Get the type info

             Type matlabtype;
             matlabtype =   Type.GetTypeFromProgID("matlab.application");

             //Create an instance of MATLAB

             object matlab;
             matlab = Activator.CreateInstance(matlabtype);

             //Prepare input as an object

             object[] arrayInput = new Object[] {"surf(peaks)"};

             //Call MATLAB method

             matlabtype.InvokeMember("Execute",BindingFlags.InvokeMethod,null,matlab,arrayInput);
         }

}

}

文章评论 (评论内容只代表网友观点,与本站立场无关!)

用户名: 查看更多评论

分 值:100分 85分 70分 55分 40分 25分 10分 0分

内 容:

         (注“”为必填内容。) 验证码: 验证码,看不清楚?请点击刷新验证码

关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 -