[求助]vb调用matlab,如何不出现matlab的图形窗
我在用VB调用MATLAB程序时,代码如下:Private Sub Command1_Click()
Dim Matlab As Object
Dim result As String
Set Matlab = CreateObject("Matlab.application")
result = Matlab.execute("t=1:5;y=cos(t);plot(t,y)")
result = Matlab.execute("print-dbitmap")
Image1.Picture = Clipboard.GetData()
End Sub
我想问下怎样才能运行时不出现matlab的图形窗
另外
vb调用matlab,如何使用GetFullMatrix。 在matlab 里面设置,查看figure命令
,做相应的处理 怎么样,问题解决了吗?如果解决了也请告诉大家哦。^_^ MY WAY:
Private Sub cmdDraw_Click()
Dim objMATLAB As Object
Set objMATLAB = CreateObject("matlab.application")
Dim strEnter As String
Dim strCommand As String
strEnter = Chr(13) & Chr(10)
strCommand = "=peaks(30);"
strCommand = strCommand & strEnter
strCommand = strCommand & "surfc(x,y,z)"
strCommand = strCommand & strEnter
strCommand = strCommand & "shading interp"
strCommand = strCommand & strEnter
strCommand = strCommand & "saveas(gcf,'c:\temp.bmp')"
objMATLAB.execute (strCommand)
imgDraw.Picture = LoadPicture("C:\temp.bmp")
imgDraw.Refresh
Set objMATLAB = Nothing
End Sub <P>请问一下 ,在vb中引用哪个才能和matlab 连接啊 /<BR></P> 有个将窗口最小化的函数,不知能不能达到你想要的结果,网上有下载的 Private Sub Command1_Click()
Dim Matlab As Object
Dim result As String
Set Matlab = CreateObject("Matlab.application")
result = Matlab.execute("figure('visible', 'off')")
result = Matlab.execute("t=1:5;y=cos(t);plot(t,y)")
result = Matlab.execute("print-dmeta")
Image1.Picture = Clipboard.GetData()
End Sub
不知行不行? 解决了一个难题,大家积极发言阿 怎样才能运行时不出现matlab的图形窗? 按bainhome的方法,可以把图绘入vb窗口,但有matlab的图形窗出现
用figure('visible','off')好像不行 原帖由 WWLLXX2001 于 2006-11-7 14:51 发表
按bainhome的方法,可以把图绘入vb窗口,但有matlab的图形窗出现
用figure('visible','off')好像不行
来个抛砖引玉
董维国老师所写的深入浅出matlab7.x混合编程中有一节是介绍
7.42 在mfc应用程序中隐藏matlab的figure窗口
我想vb vc应该类似
看能不能从中找找思路,然后应用到vb中 我用如下方法可以使figure窗口关掉,缺点是figure窗口还是会闪一下
Public Class Form1
Private Sub cmdDraw_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDraw.Click
Dim objMATLAB As Object
objMATLAB = CreateObject("matlab.application")
Dim strEnter As String
Dim strCommand As String
strEnter = Chr(13) & Chr(10)
strCommand = "=peaks(30);"
strCommand = strCommand & strEnter
strCommand = strCommand & "surfc(x,y,z);"
strCommand = strCommand & strEnter
strCommand = strCommand & "shading interp;"
strCommand = strCommand & strEnter
strCommand = strCommand & "saveas(gcf,'c:\temp.bmp');"
strCommand = strCommand & strEnter
strCommand = strCommand & "close(1)"
objMATLAB.execute(strCommand)
imgDraw.Image = Image.FromFile("C:\temp.bmp")
imgDraw.Refresh()
objMATLAB = Nothing
End Sub
End Class 把我改的拿出来和大家分享一下,大家可以测试一下
Private Sub Command1_Click()
Dim objMATLAB As Object
Set objMATLAB = CreateObject("matlab.application")
Dim strEnter As String
Dim strCommand As String
strEnter = Chr(13) & Chr(10)
strCommand = "figure('visible', 'off', 'Units','points','PaperUnits', 'points');"
strCommand = strCommand & strEnter
strCommand = strCommand & "surf(peaks(25));"
strCommand = strCommand & strEnter
strCommand = strCommand & "print -dmeta"
strCommand = strCommand & strEnter
strCommand = strCommand & "close(gcf)"
strCommand = strCommand & strEnter
objMATLAB.execute (strCommand)
imgDraw.Picture = Clipboard.GetData()
imgDraw.Refresh
Set objMATLAB = Nothing
End Sub to
WWLLXX2001
你的程序我好象运行不了,不知道问题出在什么地方
Public Class Form1
Private Sub cmdDraw_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDraw.Click
这几句不大懂,能否解释一下 我用的是visual basic 2005
在vb6.0里是运行不了的
页:
[1]
2