matlab与VB混合编程的实现步骤1111.doc_第1页
matlab与VB混合编程的实现步骤1111.doc_第2页
matlab与VB混合编程的实现步骤1111.doc_第3页
matlab与VB混合编程的实现步骤1111.doc_第4页
matlab与VB混合编程的实现步骤1111.doc_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、 首先运行mbuild setup.进行相应设置,运行结果如下: mbuild -setupPlease choose your compiler for building standalone MATLAB applications: Would you like mbuild to locate installed compilers y/n? y Select a compiler: 1 Lcc-win32 C 2.4.1 in C:MATLAB1syslcc 2 Microsoft Visual C+ 6.0 in C:Program FilesMicrosoft Visual Studio 0 None Compiler: 2 Please verify your choices: Compiler: Microsoft Visual C+ 6.0 Location: C:Program FilesMicrosoft Visual Studio Are these correct?(y/n): y Trying to update options file: C:Documents and SettingsckwjApplication DataMathWorksMATLABR2007acompopts.bat From template: C:MATLAB1binwin32mbuildoptsmsvc60compp.bat Done . . . - C:MATLAB1binwin32mwregsvr C:MATLAB1binwin32mwcomutil.dll DllRegisterServer in C:MATLAB1binwin32mwcomutil.dll succeeded - C:MATLAB1binwin32mwregsvr C:MATLAB1binwin32mwcommgr.dll DllRegisterServer in C:MATLAB1binwin32mwcommgr.dll succeeded 2、打开DEPLOYTOOL工具,进行相应选择和输入 deploytool-creat a new deployment projiect-MATLAB build for .NET-generic com component-name: shiyan.prj-location: D:COM3、建立M文件,直接拷贝代码function y = mymagic(x)y = magic(x);保存完毕4、add the file 5、deployment project setting MCR option6、build the project编译结果如下:Build output( 2008-12-27 15:52:50).mcc -F D:COMshiyan.prjmcc -W com:shiyan,shiyanclass,1.0 -d D:COMshiyansrc -T link:lib -v classshiyanclass:D:COMmymagic.m mcc -W com:shiyan,shiyanclass,1.0 -d D:COMshiyansrc -T link:lib -v classshiyanclass:D:COMmymagic.m Compiler version: 4.6 (R2007a) Processing C:MATLABR2007atoolboxmatlabmcc.enc Processing C:MATLABR2007atoolboxdatabasemcc.enc Processing include files. 2 item(s) added. Processing directories installed with MCR. The file D:COMshiyansrcmccExcludedFiles.log contains a list of functions excluded from the CTF archive. 2 item(s) added. Generating MATLAB path for the compiled application. Created 37 path items. Begin validation of MEX files: Sat Dec 27 15:53:22 2008 Validating C:MATLABR2007atoolboxcompilerdeploydeploywhich.mexw32. No conflicting M-file found. Validating C:MATLABR2007atoolboxcompilerdeployreadline.mexw32. No conflicting M-file found. End validation of MEX files: Sat Dec 27 15:53:22 2008 Deleting 2 temporary MEX authorization files. Removing: C:DOCUME1ckwjLOCALS1Tempmathworks_tmp_4147_4260.auth. Removing: C:DOCUME1ckwjLOCALS1Tempmathworks_tmp_19702_4260.auth. Parsing file D:COMmymagic.m (Referenced from: Compiler Command Line). Parsing file C:MATLABR2007atoolboxcompilerdeploymatlabrc.m (Referenced from: Compiler Command Line). Parsing file C:MATLABR2007atoolboxcompilerdirname.m (Referenced from: Compiler Command Line). Parsing file C:MATLABR2007atoolboxcompilerdeploydeployprint.m (Referenced from: Compiler Command Line). Parsing file C:MATLABR2007atoolboxcompilerdeployprintdlg.m (Referenced from: Compiler Command Line). Parsing file C:MATLABR2007atoolboxmatlabelmatmagic.m (Referenced from: D:COMmymagic.m). Parsing file C:MATLABR2007atoolboxmatlabiofunfilesep.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploymatlabrc.m). Parsing file C:MATLABR2007atoolboxcompilerdeployhgrc.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploymatlabrc.m). Parsing file C:MATLABR2007atoolboxmatlabcodetoolsinitdesktoputils.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploymatlabrc.m). Parsing file C:MATLABR2007atoolboxlocalinitprefs.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploymatlabrc.m). Parsing file C:MATLABR2007atoolboxmatlabgeneralisdeployed.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploymatlabrc.m). Parsing file C:MATLABR2007atoolboxmatlabgeneralispc.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploymatlabrc.m). Parsing file C:MATLABR2007atoolboxmatlablanglasterror.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploymatlabrc.m). Parsing file C:MATLABR2007atoolboxlocalpathdef.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploymatlabrc.m). Parsing file C:MATLABR2007atoolboxmatlabgeneralpwd.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploymatlabrc.m). Parsing file C:MATLABR2007atoolboxmatlabgeneralrecycle.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploymatlabrc.m). Parsing file C:MATLABR2007atoolboxlocalreporterrorlogs.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploymatlabrc.m). Parsing file C:MATLABR2007atoolboxmatlabstrfunstr2double.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploymatlabrc.m). Parsing file C:MATLABR2007atoolboxmatlabgeneralusejava.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploymatlabrc.m). Parsing file C:MATLABR2007atoolboxmatlabiofunfileparts.m (Referenced from: C:MATLABR2007atoolboxcompilerdirname.m). Parsing file C:MATLABR2007atoolboxmatlabtimefundatestr.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploydeployprint.m). Parsing file C:MATLABR2007atoolboxmatlabgraphicsgetappdata.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploydeployprint.m). Parsing file C:MATLABR2007atoolboxmatlabdatatypesisfield.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploydeployprint.m). Parsing file C:MATLABR2007atoolboxmatlabuitoolsmsgbox.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploydeployprint.m). Parsing file C:MATLABR2007atoolboxmatlabtimefunnow.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploydeployprint.m). Parsing file C:MATLABR2007atoolboxmatlabdatatypesnum2cell.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploydeployprint.m). Parsing file C:MATLABR2007atoolboxmatlabstrfunnum2str.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploydeployprint.m). Parsing file C:MATLABR2007atoolboxmatlabgraphicsorient.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploydeployprint.m). Parsing file C:MATLABR2007atoolboxmatlabgraphicsprint.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploydeployprint.m). Parsing file C:MATLABR2007atoolboxmatlabstrfunstr2num.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploydeployprint.m). Parsing file C:MATLABR2007atoolboxmatlabiofuntempname.m (Referenced from: C:MATLABR2007atoolboxcompilerdeploydeployprint.m). Parsing file C:MATLABR2007atoolboxmatlabgeneralpath.m (Referenced from: C:MATLABR2007atoolboxcompilerdeployprintdlg.m). Parsing file C:MATLABR2007atoolboxmatlabgeneralrmpath.m (Referenced from: C:MATLABR2007atoolboxcompilerdeployprintdlg.m). Generating file D:COMshiyansrcshiyan_idl.idl. Generating file D:COMshiyansrcshiyanclass_com.hpp. Generating file D:COMshiyansrcshiyanclass_com.cpp. Generating file D:COMshiyansrcshiyan_dll.cpp. Generating file D:COMshiyansrcshiyan.def. Generating file D:COMshiyansrcshiyan.rc. Generating file D:COMshiyansrcreadme.txt. Generating file D:COMshiyansrcshiyan_mcc_component_data.c. Executing command: mbuild -O -v -output shiyan_1_0 -ID:COMshiyansrc mwcomtypes.idl D:COMshiyansrcshiyan_idl.idl mclcommain.lib D:COMshiyansrcshiyanclass_com.cpp D:COMshiyansrcshiyan_dll.cpp D:COMshiyansrcshiyan.def D:COMshiyansrcshiyan.rc D:COMshiyansrcshiyan_mcc_component_data.c -link dll -outdir D:COMshiyansrc -regsvr This is mbuild Copyright 1984-2006 The MathWorks, Inc. - Default options filename found in C:Documents and SettingsckwjApplication DataMathWorksMATLABR2007a - - Options file = C:Documents and SettingsckwjApplication DataMathWorksMATLABR2007acompopts.bat - COMPILER = cl - Compiler flags: COMPFLAGS = -c -Zp8 -G5 -GX -W3 -nologo -IC:MATLAB1externincludewin32 -DMSVC -DIBMPC -DMSWIND OPTIMFLAGS = -O2 -DNDEBUG DEBUGFLAGS = -Zi -FdD:COMshiyansrcshiyan_1_0.pdb arguments = -ID:COMshiyansrc Name switch = /Fo - Pre-linking commands = - LINKER = link - Link directives: LINKFLAGS = kernel32.lib user32.lib gdi32.lib advapi32.lib oleaut32.lib ole32.lib /LIBPATH:C:MATLAB1externlibwin32microsoft /nologo mclmcrrt.lib /dll /implib:D:COMshiyansrcshiyan_1_0.lib /def:D:COMshiyansrcshiyan.def LINKFLAGSPOST = Name directive = /out:D:COMshiyansrcshiyan_1_0.dll File link directive = Lib. link directive = Rsp file indicator = - Resource Compiler = rc /fo D:COMshiyansrcshiyan.res - Resource Linker = - - copy C:MATLAB1externincludewin32mwcomutil.tlb . ? 1 ?t? - midl /nologo /win32 /I C:MATLAB1externinclude /D NDEBUG /out D:COMshiyansrc mwcomtypes.idl mwcomtypes.idl oaidl.idl objidl.idl unknwn.idl wtypes.idl ocidl.idl oleidl.idl servprov.idl urlmon.idl msxml.idl Processing C:MATLAB1externincludemwcomtypes.idl Processing C:Program FilesMicrosoft Visual StudioVC98INCLUDEoaidl.idl Processing C:Program FilesMicrosoft Visual StudioVC98INCLUDEobjidl.idl Processing C:Program FilesMicrosoft Visual StudioVC98INCLUDEunknwn.idl Processing C:Program FilesMicrosoft Visual StudioVC98INCLUDEwtypes.idl Processing C:Program FilesMicrosoft Visual StudioVC98INCLUDEocidl.idl Processing C:Program FilesMicrosoft Visual StudioVC98INCLUDEoleidl.idl Processing C:Program FilesMicrosoft Visual StudioVC98INCLUDEservprov.idl Processing C:Program FilesMicrosoft Visual StudioVC98INCLUDEurlmon.idl Processing C:Program FilesMicrosoft Visual StudioVC98INCLUDEmsxml.idl - midl /nologo /win32 /I C:MATLAB1externinclude /D NDEBUG /out D:COMshiyansrc D:COMshiyansrcshiyan_idl.idl shiyan_idl.idl oaidl.idl objidl.idl unknwn.idl wtypes.idl ocidl.idl oleidl.idl servprov.idl urlmon.idl msxml.idl mwcomtypes.idl Processing D:COMshiyansrcshiyan_idl.idl Processing C:Program FilesMicrosoft Visual StudioVC98INCLUDEoaidl.idl Processing C:Program FilesMicrosoft Visual StudioVC98INCLUDEobjidl.idl Processing C:Program FilesMicrosoft Visual StudioVC98INCLUDEunknwn.idl Processing C:Program FilesMicrosoft Visual StudioVC98INCLUDEwtypes.idl Processing C:Program FilesMicrosoft Visual StudioVC98INCLUDEocidl.idl Processing C:Program FilesMicrosoft Visual StudioVC98INCLUDEoleidl.idl Processing C:Program FilesMicrosoft Visual StudioVC98INCLUDEservprov.idl Processing C:Program FilesMicrosoft Visual StudioVC98INCLUDEurlmon.idl Processing C:Program FilesMicrosoft Visual StudioVC98INCLUDEmsxml.idl Processing C:MATLAB1externincludemwcomtypes.idl - del mwcomutil.tlb - cl -ID:COMshiyansrc -c -Zp8 -G5 -GX -W3 -nologo -IC:MATLAB1externincludewin32 -DMSVC -DIBMPC -DMSWIND /FoC:DOCUME1ckwjLOCALS1Tempmbuild_085BF459-513B-4CF7-8F8C-E67F54D4BB97shiyanclass_com.obj -IC:MATLAB1externinclude -IC:MATLAB1simulinkinclude -O2 -DNDEBUG D:COMshiyansrcshiyanclass_com.cpp shiyanclass_com.cpp - cl -ID:COMshiyansrc -c -Zp8 -G5 -GX -W3 -nologo -IC:MATLAB1externincludewin32 -DMSVC -DIBMPC -DMSWIND /FoC:DOCUME1ckwjLOCALS1Tempmbuild_085BF459-513B-4CF7-8F8C-E67F54D4BB97shiyan_dll.obj -IC:MATLAB1externinclude -IC:MATLAB1simulinkinclude -O2 -DNDEBUG D:COMshiyansrcshiyan_dll.cpp shiyan_dll.cpp - cl -ID:COMshiyansrc -c -Zp8 -G5 -GX -W3 -nologo -IC:MATLAB1externincludewin32 -DMSVC -DIBMPC -DMSWIND /FoC:DOCUME1ckwjLOCALS1Tempmbuild_085BF459-513B-4CF7-8F8C-E67F54D4BB97shiyan_mcc_component_data.obj -IC:MATLAB1externinclude -IC:MATLAB1simulinkinclude -O2 -DNDEBUG D:COMshiyansrcshiyan_mcc_component_data.c shiyan_mcc_component_data.c - rc /fo D:COMshiyansrcshiyan.res D:COMshiyansrcshiyan.rc Contents of C:DOCUME1ckwjLOCALS1Tempmbuild_085BF459-513B-4CF7-8F8C-E67F54D4BB97mbuild_tmp.rsp: mclcommain.lib C:DOCUME1ckwjLOCALS1Tempmbuild_085BF459-513B-4CF7-8F8C-E67F54D4BB97shiyanclass_com.obj C:DOCUME1ckwjLOCALS1Tempmbuild_085BF459-513B-4CF7-8F8C-E67F54D4BB97shiyan_dll.obj C:DOCUME1ckwjLOCALS1Tempmbuild_085BF459-513B-4CF7-8F8C-E67F54D4BB97shiyan_mcc_component_data.obj D:COMshiyansrcshiyan.res - link /out:D:COMshiyansrcshiyan_1_0.dll kernel32.lib user32.lib gdi32.lib advapi32.lib oleaut32.lib ole32.lib /LIBPATH:C:MATLAB1externlibwin32microsoft /nologo mclmcrrt.lib /dll /implib:D:COMshiyansrcshiyan_1_0.lib /def:D:COMshiyansrcshiyan.def C:DOCUME1ckwjLOCALS1Tempmbuild_085BF459-513B-4CF7-8F8C-E67F54D4BB97mbuild_tmp.rsp Creating library D:COMshiyansrcshiyan_1_0.lib and object D:COMshiyansrcshiyan_1_0.exp - if exist C:DOCUME1ckwjLOCALS1Tempmbuild_085BF459-513B-4CF7-8F8C-E67F54D4BB97templib.def del C:DOCUME1ckwjLOCALS1Tempmbuild_085BF459-513B-4CF7-8F8C-E67F54D4BB97templib.def - mwregsvr D:COMshiyansrcshiyan_1_0.dll DllRegisterServer in D:COMshiyansrcshiyan_1_0.dll succeeded Copying: D:COMshiyansrcshiyan_1_0.dll - D:COMshiyandistribCopying: D:COMshiyansrcshiyan.ctf - D:COMshiyandistribCompilation completed succesfully. The output is located in D:COMshiyandistrib.You can package the component by clicking on the Package icon in the Deployment Tool toolbar, or by clicking the Tools-Package menu when the Deployment Tool panel is selected. To include additional files in the package, click Project-Settings).7、打开VB根据HELP文件编写VB程序新建工程-标准EXE-引用shiyan1.0 trpe library-部件Microsoft Windows Common -添加各种控件并相应修改属性-编写代码如下:Private Sub Form_Load()This function is called when the form is loaded.Creates a new magic class instance. On Error GoTo Handle_Error Set theMagic = New shiyan.shiyanclass Size = 0Exit SubHandle_Error: MsgBox (Err.Description)End SubPrivate Sub btnCreate_Click()This function is called when the Create button is pressed.Calls the mymagic method, and displays the magic square. Dim y As Variant If Size = 0 Or theMagic Is Nothing Then Exit Sub On Error GoTo Handle_Error Call theMagic.mymagic(1, y, Size) Call ShowMatrix(y) Exit SubHandle_Error: MsgBox (Err.Description)End SubPrivate Sub edtSize_Change()This function is called when ever the contents of theText box change. Sets the current value of Size. On Error Resume Next Size = CDbl(edtSize.Text)

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论