0

我很好奇是否可以将 matlab gui 添加到 powerpoint 演示文稿中。在演示文稿或打开 matlab 的链接中。

我调用这个函数,它会打开图形然后立即关闭它。

Private Sub click_Click()
Call RunFile("new_control_pan", "C:\Users\mhaartman\Documents\PANE_golden2\PANE_golden\code")
End Sub

Sub RunFile(FILENAME As String, Optional FilePath As String)
Dim MATLAB As Object
Dim Result As String
Dim Command As String
Dim MATLABWasNotRunning As Boolean
'''''''''''''''''''''''''''''''''''''''''''''''''''
' Set Up
'''''''''''''''''''''''''''''''''''''''''''''''''''
' Connect to the automation server.
' MATLAB becomes a MATLAB handle to the running instance
' of MATLAB.
On Error Resume Next ' Defer error trapping
MATLAB = GetObject(, "matlab.application") 
If Err.Number <> 0 Then
MATLABWasNotRunning = True
Set MATLAB = CreateObject("matlab.application")
Err.Clear ' Clear Err object in case error occurred.
End If
'''''''''''''''''''''''''''''''''''''''''''''''''''
' Do the Work
'''''''''''''''''''''''''''''''''''''''''''''''''''
If Not IsMissing(FilePath) And Not FilePath = "" Then
Command = "cd('" + FilePath + "')"
Result = MATLAB.Execute(Command)
End If
Command = FILENAME
Result = MATLAB.Execute(Command)

'Result = MsgBox("Done", vbOkayOnly, "Click when done")
End Sub

谢谢!

4

1 回答 1

2

也许你可以看看Calling MATLAB from PowerPoint。这个在 File Exchange 上的提交可能已经过时了,因为它是几年前创建的。但是最新版本的 MATLAB 通常继续提供 COM 接口,可以从 PowerPoint 中调用。它可能需要一些更新,但我确信任何问题都是可以纠正的。

于 2012-08-06T09:28:23.820 回答