Matlab2012a与VS2010(C++)混合编程选编.docx

  1. 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Matlab2012a与VS2010(C)混合编程选编

Matlab2012a与VS2010(C++)混合编程 经历了各种报错和崩溃,用了近1个月的时间终于把C++的程序调通了。在编程过程中,我在网上找了各种Matlab和C++混编的资料,感觉混编的资料太少,故将自己编程的过程和心得分享给大家,希望能帮到和我一样挣扎在混编领域中的同学。 环境:windows8.1,Matlab2012a,VS2010 需要编的C++程序要实现与Matlab一样的功能,从键盘输入数据,获得计算结果和图像。如下图: 大概的过程:Matlab的m文件→dll→C++调用dll和Matlab中的engine(与图像有关,后面会详细说明)→输出计算结果和图像 1.Matlab编译器设置(电脑安装有VS2010) (1)mex命令设置 (a) 运行 Matlab ,在 Matlab 的命令窗口 (Command Window) 键入“ mex -setup ”命令后,按回车键,安装 Matlab 编译器; (b) 命令窗口出现如下提示: Please choose your compiler for building external interface (MEX) files: Would you like mex to locate installed compilers [y]/n? 此时键入 “y” ,按回车; (c) 命令窗口出现如下提示: Please choose your compiler for building external interface (MEX) files: Would you like mex to locate installed compilers [y]/n? y Select a compiler: [1] Microsoft Visual Studio 2010 in G:\ Visual Studio 2010 [0] None 此时键入 ” 1” ,按回车 ;选择 Microsoft Visual Studio 2010 的编译器 (d) 命令窗口出现如下提示: Please verify your choices: Compiler: Microsoft Visual Studio 2010 Location: G:\ Visual Studio 2010 Are these correct?([y]/n): 此时键入 ”y” ,按回车 ;确认选择 Microsoft Visual Studio 2010 的编译器 (2) mbuild 命令设置 (a) 运行 Matlab ,在 Matlab 的命令窗口 (Command Window) 键入“ mbuild -setup ”命令后,按回车键,安装 Matlab 编译器; (b) 命令窗口出现如下提示: Please choose your compiler for building standalone MATLAB applications: Would you like mbuild to locate installed compilers [y]/n? 此时键入 ”y” ,按回车 ; (c) 命令窗口出现如下提示: [1] Microsoft Visual Studio 2010 in G:\ Visual Studio 2010 [0] None 此时键入 “ 1” ,按回车 ;选择 Microsoft Visual Studio 2010 的编译器 (d) 命令窗口出现如下提示: Please verify your choices: Compiler: Microsoft Visual Studio 2010 Location: G:\ Visual Studio 2010 Are these correct?([y]/n): 此时键入 ”y” ,按回车 ,确认选择 Microsoft Visual Studio 2010 的编译器,编译器设置完成。 2. 将 Matlab 函数转成 DLL 函数 (tips:能封装成dll文件的m文件其内容必须是自定义函数形式) 函数文件 RE_1.m ,内容如下: function [f0,f1,f2]=RE_1(S0,S1,S2) x = 0:0.01:2*pi; r =cos(3*x)/5 - (3*cos(6*x))/5 + (7*cos(20*x))/10 + sin(2*x)/10 + (3*sin(13*x))/10 + 10; r_max = max(r); r_min = min(r); r1=r_max; r2=r_min; f0=r1-r2; N=128; p1=19; p2=64; c0=1; c1=-s

文档评论(0)

jiayou10 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8133070117000003

1亿VIP精品文档

相关文档