手把手教你C_调用MATLAB函数

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

【转载】手把手教你用C#调用MATLAB函数

编译环境:Microsoft Visual Studio 2008

版本9.0.21022.8 RTM

Microsoft .NET Framework

版本3.5

已安装的版本: Professional

Microsoft Visual Basic 2008 91986-031-5000002-60050

Microsoft Visual Basic 2008

Microsoft Visual C# 2008 91986-031-5000002-60050

Microsoft Visual C# 2008

Microsoft Visual C++ 2008 91986-031-5000002-60050

Microsoft Visual C++ 2008

Microsoft Visual Studio 2008 Tools for Office 91986-031-5000002-60050

Microsoft Visual Studio 2008 Tools for Office

Microsoft Visual Web Developer 2008 91986-031-5000002-60050

Microsoft Visual Web Developer 2008

Crystal Reports AAJ6G-K0MSA4K-680002Z

Crystal Reports Basic for Visual Studio 2008

Matlab 2008b

首先需要做的工作是matlab编译器的设置,设置方法为:在Command window中输入mbuild -setup 显示如下

>> mbuild -setup

Please choose your compiler for building standalone MATLAB applications:

Would you like mbuild to locate installed compilers [y]/n? n %选择n

Select a compiler:

[1] Lcc-win32 C 2.4.1

[2] Microsoft Visual C++ 6.0

[3] Microsoft Visual C++ .NET 2003

[4] Microsoft Visual C++ 2005

[5] Microsoft Visual C++ 2005 Express Edition

[6] Microsoft Visual C++ 2008

[0] None

Compiler: 6 %选择6,其他编译器可以选相应的选项,我没有验证过The default location for Microsoft Visual C++ 2008 compilers is C:\Program Files\Microsoft Visual Studio 9.0,

but that directory does not exist on this machine.

Use C:\Program Files\Microsoft Visual Studio 9.0 anyway [y]/n? n%选择n

Please enter the location of your compiler: [C:\Program Files\Microsoft Visual Studio 9.0] D:\Program Files\Microsoft Visual Studio 9.0 %选择您自己的当前安装路径

Please verify your choices:

Compiler: Microsoft Visual C++ 2008

Location: D:\Program Files\Microsoft Visual Studio 9.0

Are these correct [y]/n? y %看上述信息,如果正确选择y

**************************************************************************** Warning: Applications/components generated using Microsoft Visual Studio

2008 require that the Microsoft Visual Studio 2008 run-time

libraries be available on the computer used for deployment.

To redistribute your applications/components, be sure that the

deployment machine has these run-time libraries.

****************************************************************************

Trying to update options file: C:\Documents and Settings\Administrator\Application Data\MathWorks\MATLAB\R2008b\compopts.bat

From template: D:\PROGRA~1\MA TLAB\R2008b\bin\win32\mbuildopts\msvc90compp.bat

Done . . .

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%至次编译器设置完成%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

在matlab的Command window中输入:

>> deploytool

Matlab产生deployment tool配置窗口

单击新建按钮,新建工程------>选择MATLAB Builder NE 选项卡----->选择.NET Component 并添加工程名eaqual(测试用名,其实工程名称就是你导入C#后的命名空间名称,Matlab会在当前工作目录中新建文件夹文件夹名既为equal)---->点击ADD File按钮将你需要编译的MATLAB函数添加进当前工程,我这里导入的是D:\Program Files\MATLAB\R2008b\toolbox\aero\aero\angle2quat.m文件---->点击build.

deployment tool output 窗口输出以下信息:

Build output( 2009-03-28 15:32:55).

[url=matlab:mcc%20-F%20%27E:%5CMATLAB%5Ceaqual.prj%27]mcc -F 'E:\MATLAB\eaqual.prj'[/url]

等待...................................有点久

当输出以下信息时编译成功了

Compiler version: 4.9 (R2008b) Warning: Duplicate directory name: E:\MATLAB. mcc -W 'dotnet:eaqual,Eaqual,0.0,private' -d 'E:\MATLAB\eaqual\src' -T 'link:lib' -v

'class{Eaqual:\Program Files\MATLAB\R2008b\toolbox\aero\aero\angle2quat.m}'

相关文档
最新文档