1. 用mcc生成独立的外部应用程序。可使用如下两种命令:
mcc -p file.m 或 mcc -m file.m
2. 在VB中声明调用的三个API函数:
● Declare Function WaitForSingleObject Lib “kernel32”(ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
● Declare Function CloseHandle Lib “kernel32”(ByVal hObject As Long) As Long
● Declare Function OpenProcess Lib “kernel32”(ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long,ByVal dwProcessId As Long) As Long
3. 示例代码:
Dim lTask As Long, lret As Long, lHandle As Long
’执行file.exe文件
lTask = Shell(“file.exe”, vbNormalFocus)
lHandle = OpenProcess(SYNCHRONIZE, False, lTask)
’等待进程执行完毕
lret = WaitForSingleObject(lHandle, INFINITE)
lret = CloseHandle(lHandle)
’ file.exe文件执行完毕后,继续执行应用程序
……
通过以上编码,应用程序可以在执行过程中销脊调用.EXE完成特定的计算或图形功能后,再继续其执行过程,从而实现与含兄Matlab的集成。
Set Matlab = CreateObject("Matlab. Application")这句中,matlab.和Application之间不要有空格。
还有前面要有Set,look下面凯态纤:
Public Matlab As Object
Private Sub Button1_Click()
Set Matlab = CreateObject("Matlab.Application"盯仿闭腔)
Call Matlab.MinimizeCommandWindow
Call Matlab.Execute("clca=[1,2,34,5,6]b=[4,5,61,2,3]c=a+b")
End Sub
有个Matlab组件,可祥没以下载安装在系统里,在旦颂VB里添加组件,然后即可使用来结合VB和Matlab实现绘图,计模宴郑算,函数编程。如何在VB界面里运行matlab - VB6论坛 - 编程论坛
http://bbs.bccn.net/thread-235012-1-1.html
http://download.csdn.net/detail/mmfang2/4731773
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)