标题:求助:vb调用MATLAB问题(数组数据传不过去)
取消只看楼主
xiaohuage22
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-5-22
 问题点数:0 回复次数:0 
求助:vb调用MATLAB问题(数组数据传不过去)
要求:在VB界面输入传递函数(数组形式,现在问题可能就 是数组没能够传到MATLAB中)


VB程序如下(有些参数多设置了)


Dim matlab As Object
Option Base 0
 
Public p As Integer
Public g As Integer



Private Sub Command1_Click()
Dim H() As Double
Dim i As Double, k As Double, w As Double, j As Double
k = Text1.Text
p = k
w = Text2.Text
g = w
Dim L1() As Double
Dim L2() As Double



ReDim L1(0 To k - 1) As Double
ReDim L2(0 To w - 1) As Double



For i = 0 To k - 1

L1(i) = List1.List(i)

Next i


For j = 0 To w - 1

L2(j) = List2.List(j)

Next j


Set matlab = CreateObject("Matlab.Application")



Call matlab.putfullmatrix("I", "base", L1, H)

Call matlab.putfullmatrix("J", "base", L2, H)


matlab.execute ("xyz")

Call matlab.minimizecommandwindow

matlab.execute ("print( gcf, '-djpeg', 'c:\Test1')")

Call matlab.quit
Set matlab = Nothing


Form7.Show

End Sub

Private Sub Command2_Click()
Dim a() As Integer
Dim i As Integer, j As Integer, n As Integer
j = Text1.Text
ReDim a(j)
For i = 1 To UBound(a)
n = InputBox("输入一个数据:")
List1.AddItem n
Next i
End Sub


Private Sub Command3_Click()
Dim a() As Integer
Dim i As Integer, j As Integer, n As Integer
j = Text2.Text
ReDim a(j)
For i = 1 To UBound(a)
n = InputBox("输入一个数据:")
List2.AddItem n
Next i
End Sub




MATLAB M 文件



sys=tf(I,J);
sys2=feedback(sys,1)
step(sys2)



如果在MATLAB中给I,J赋值,会有图形在VB中出现。
搜索更多相关主题的帖子: MATLAB Double Dim 数据 Integer 
2008-05-22 17:23



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-215646-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.053069 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved