⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 坦克的识别.frm

📁 用VB编写的模式识别程序(包括:坦克的识别
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form2 
   Caption         =   "Form1"
   ClientHeight    =   4500
   ClientLeft      =   4950
   ClientTop       =   3990
   ClientWidth     =   6150
   LinkTopic       =   "Form1"
   ScaleHeight     =   4500
   ScaleWidth      =   6150
   Begin VB.CommandButton Command5 
      Caption         =   "细胞的识别"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   4320
      TabIndex        =   9
      Top             =   3600
      Width           =   1455
   End
   Begin VB.CommandButton Command4 
      Caption         =   "阑尾炎诊断"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   4320
      TabIndex        =   8
      Top             =   2880
      Width           =   1455
   End
   Begin VB.CommandButton Command3 
      Caption         =   "最大似然"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   11.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   4080
      TabIndex        =   7
      Top             =   1800
      Width           =   1215
   End
   Begin VB.CommandButton Command2 
      Caption         =   "最小风险"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   11.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   2400
      TabIndex        =   6
      Top             =   1800
      Width           =   1335
   End
   Begin VB.CommandButton Command1 
      Caption         =   "最小错误率"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   11.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   720
      TabIndex        =   5
      Top             =   1800
      Width           =   1335
   End
   Begin VB.TextBox Text2 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   1920
      MultiLine       =   -1  'True
      TabIndex        =   3
      Top             =   3120
      Width           =   1815
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Index           =   1
      Left            =   4320
      TabIndex        =   2
      Top             =   960
      Width           =   975
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Index           =   0
      Left            =   1560
      TabIndex        =   1
      Top             =   960
      Width           =   975
   End
   Begin VB.Label Label4 
      Caption         =   "P(x|ω2)="
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3120
      TabIndex        =   11
      Top             =   960
      Width           =   1095
   End
   Begin VB.Label Label3 
      Caption         =   "P(x|ω1)="
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   360
      TabIndex        =   10
      Top             =   960
      Width           =   1215
   End
   Begin VB.Label Label2 
      Caption         =   "判决结果:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   600
      TabIndex        =   4
      Top             =   3240
      Width           =   1215
   End
   Begin VB.Label Label1 
      Caption         =   "请输入样本的类条件概率密度"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   360
      TabIndex        =   0
      Top             =   360
      Width           =   3855
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim pw(1) As Single, P(1) As Single, L(2, 1) As Single
Dim i As Integer
Private Function texttest()
  texttest = 1
  For i = 0 To 1
    If Text1(i).Text = "" Then
       MsgBox "请输入类条件概率", 16, "错误"
       texttest = 0
       Exit Function
    End If
  Next
  For i = 0 To 1
    If Text1(i).Text > 1 Or Text1(i).Text < 0 Then
       MsgBox "请输入正确的数值", 16, "错误"
       texttest = 0
       Exit Function
    End If
  Next
End Function

Private Sub Command1_Click()
  If texttest = 0 Then Exit Sub
  For i = 0 To 1
  P(i) = CSng(Text1(i).Text) * pw(i)
  Next
  If P(0) > P(1) Then
     Text2.Text = "坦克"
  ElseIf P(0) < P(1) Then Text2.Text = "灌木丛"
  Else: Text2.Text = "可能是坦克,也可能是灌木丛"
  End If
End Sub

Private Sub Command2_Click()
  If texttest = 0 Then Exit Sub
  Dim pwx(1) As Single, px As Single, R(2) As Single
  For i = 0 To 1
  P(i) = CSng(Text1(i).Text) * pw(i)
  px = px + P(i)
  Next
  pwx(0) = P(0) / px: pwx(1) = P(1) / px
  For i = 0 To 2
  R(i) = L(i, 0) * pwx(0) + L(i, 1) * pwx(1)
  Next
  If R(0) < R(1) Then
     If R(0) < R(2) Then
       Text2.Text = "坦克"
     Else: Text2.Text = "拒绝判决"
     End If
  ElseIf R(1) < R(0) Then
     If R(1) < R(2) Then
       Text2.Text = "灌木丛"
     Else: Text2.Text = "拒绝判决"
     End If
  Else: Text2.Text = "拒绝判决"
  End If
End Sub

Private Sub Command3_Click()
  If texttest = 0 Then Exit Sub
  Dim MX As Single, L12 As Single
  MX = pw(1) / pw(0)
  L12 = CSng(Text1(0).Text) / CSng(Text1(1).Text)
  If L12 < MX Then
     Text2.Text = "灌木丛"
  Else: Text2.Text = "坦克"
  End If
End Sub

Private Sub Command4_Click()
  Unload Form2
  Load Form1
  Form1.Show
End Sub

Private Sub Command5_Click()
  Unload Form2
  Load Form3
  Form3.Show
End Sub

Private Sub Form_Load()
  pw(0) = 0.7: pw(1) = 0.3
  L(0, 0) = 0.5: L(0, 1) = 2: L(1, 0) = 4: L(1, 1) = 1: L(2, 0) = 1.5: L(2, 1) = 1.5
  
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -