求助: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中出现。