📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 6180
ClientLeft = 60
ClientTop = 450
ClientWidth = 9210
LinkTopic = "Form1"
ScaleHeight = 6180
ScaleWidth = 9210
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command3
Caption = "关闭"
Height = 375
Left = 7440
TabIndex = 5
Top = 4800
Width = 1575
End
Begin VB.CommandButton Command2
Caption = "下一个"
Height = 375
Left = 7440
TabIndex = 3
Top = 1920
Width = 1455
End
Begin VB.TextBox Text1
Height = 375
Left = 7440
TabIndex = 2
Text = "0"
Top = 1080
Width = 1455
End
Begin VB.CommandButton Command1
Caption = "计算"
Height = 375
Left = 7440
TabIndex = 1
Top = 3840
Width = 1455
End
Begin VB.ComboBox Combo1
Height = 315
ItemData = "Form1.frx":0000
Left = 7440
List = "Form1.frx":0002
TabIndex = 0
Text = "选择运算"
Top = 2880
Width = 1455
End
Begin VB.Label Label1
Caption = "Label1"
Height = 375
Left = 7200
TabIndex = 4
Top = 360
Width = 1815
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim matrix(1 To 4, 1 To 4) As Double
Dim matlabObject As Object
Dim i As Integer
Dim j As Integer
Private Sub Command1_Click()
Dim matrixr(1 To 4, 1 To 4) As Double '用于保存转置或求逆后的结果
Dim matrixi() As Double
Dim chrisr(1 To 4) As Double '用于保存计算特征值后的结果
Dim chrisi(1 To 4) As Double
Dim row As Integer
Dim col As Integer
Call matlabObject.PutFullMatrix("T", "base", matrix, matrixi)
If Combo1.Text = "转置" Then
matlabObject.Execute ("a=T'")
Call matlabObject.GetFullMatrix("a", "base", matrixr, matrixi)
Print "转置"
For row = 1 To 4
For col = 1 To 4
Print matrixr(row, col);
Next
Print
Next
ElseIf Combo1.Text = "逆矩阵" Then
matlabObject.Execute ("a=inv(T)")
Call matlabObject.GetFullMatrix("a", "base", matrixr, matrixi)
Print "逆矩阵"
For row = 1 To 4
For col = 1 To 4
Print matrixr(row, col);
Next
Print
Next
ElseIf Combo1.Text = "特征值" Then
matlabObject.Execute ("a=eig(T)")
Call matlabObject.GetFullMatrix("a", "base", chrisr, chrisi)
Print "特征值"
For row = 1 To 4
Print chrisr(row);
Print
Next
Else
Exit Sub
End If
End Sub
Private Sub Command2_Click()
'On Error GoTo aaa
Dim row As Integer
Dim col As Integer
If i > 4 Then
i = 1
j = 1
Text1.Text = ""
MsgBox "输入已经结束"
Exit Sub
End If
Label1.Caption = "当前行,列为" & CStr(i) & ", " & CStr(j)
matrix(i, j) = CDbl(Text1.Text)
Print matrix(i, j);
If j Mod 4 = 0 Then
i = i + 1
j = 1
Print
Else
j = j + 1
End If
Text1.Text = "0"
'aaa:
'Exit Sub
End Sub
Private Sub Command3_Click()
Unload Form1
End Sub
Private Sub Form_Load()
Combo1.AddItem "转置"
Combo1.AddItem "逆矩阵"
Combo1.AddItem "特征值"
i = 1
j = 1
Set matlabObject = CreateObject("matlab.Application")
End Sub
Private Sub OLE1_Updated(Code As Integer)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -