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

📄 form1.frm

📁 信号源的产生及序列的卷积。输入不同序列
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   9135
   ClientLeft      =   60
   ClientTop       =   465
   ClientWidth     =   14130
   LinkTopic       =   "Form1"
   ScaleHeight     =   9135
   ScaleWidth      =   14130
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command3 
      Caption         =   "卷积"
      Height          =   615
      Left            =   1440
      TabIndex        =   14
      Top             =   7320
      Width           =   1215
   End
   Begin VB.CommandButton Command2 
      Caption         =   "序列"
      Height          =   495
      Left            =   3120
      TabIndex        =   13
      Top             =   4560
      Width           =   735
   End
   Begin VB.CommandButton Command1 
      Caption         =   "序列"
      Height          =   495
      Left            =   3120
      TabIndex        =   12
      Top             =   2160
      Width           =   735
   End
   Begin VB.OptionButton Option3 
      Caption         =   "指数"
      Height          =   375
      Left            =   720
      TabIndex        =   11
      Top             =   2760
      Width           =   1575
   End
   Begin VB.OptionButton Option2 
      Caption         =   "矩形"
      Height          =   375
      Left            =   720
      TabIndex        =   10
      Top             =   2160
      Width           =   1575
   End
   Begin VB.OptionButton Option1 
      Caption         =   "正弦"
      Height          =   375
      Left            =   720
      TabIndex        =   9
      Top             =   1560
      Value           =   -1  'True
      Width           =   1575
   End
   Begin VB.PictureBox Picture3 
      Height          =   2415
      Left            =   3360
      ScaleHeight     =   2355
      ScaleWidth      =   8595
      TabIndex        =   8
      Top             =   6360
      Width           =   8655
   End
   Begin VB.PictureBox Picture2 
      Height          =   2055
      Left            =   4200
      ScaleHeight     =   1995
      ScaleWidth      =   7755
      TabIndex        =   7
      Top             =   3840
      Width           =   7815
   End
   Begin VB.PictureBox Picture1 
      Height          =   2055
      Left            =   4200
      ScaleHeight     =   1995
      ScaleWidth      =   7755
      TabIndex        =   6
      Top             =   1320
      Width           =   7815
   End
   Begin VB.TextBox Text3 
      Height          =   495
      Left            =   6600
      TabIndex        =   5
      Text            =   "5"
      Top             =   360
      Width           =   855
   End
   Begin VB.TextBox Text2 
      Height          =   495
      Left            =   4080
      TabIndex        =   3
      Text            =   "10"
      Top             =   360
      Width           =   855
   End
   Begin VB.TextBox Text1 
      Height          =   495
      Left            =   1560
      TabIndex        =   1
      Text            =   "1"
      Top             =   360
      Width           =   855
   End
   Begin VB.Label Label3 
      Caption         =   "抽样频率"
      Height          =   255
      Left            =   5640
      TabIndex        =   4
      Top             =   480
      Width           =   735
   End
   Begin VB.Label Label2 
      Caption         =   "时间长度"
      Height          =   255
      Left            =   3120
      TabIndex        =   2
      Top             =   480
      Width           =   735
   End
   Begin VB.Label Label1 
      Caption         =   "信号频率"
      Height          =   255
      Left            =   600
      TabIndex        =   0
      Top             =   480
      Width           =   735
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Const pi = 3.1415926
Dim f0, t, fs As Double
Dim a(1000), b(-500 To 1000), c(1000)
Dim n As Integer

Private Sub Command1_Click()
Dim x, y
If (Option1.Value = True) Then
    Picture1.Cls
    n = 0
    For j = 0 To 1000
        a(j) = 0
    Next
    
    Picture1.Scale (0, 2)-(30, -2)
    Picture1.Line (0, 0)-(30, 0)
    For x = 0 To t Step 1 / fs
        y = Sin(f0 * x)
        Picture1.Line (x, y)-(x, 0)
        a(n) = y
        n = n + 1
    Next x

ElseIf (Option2.Value = True) Then
    For j = 0 To 1000
        a(j) = 0
    Next
    
    Picture1.Cls
    n = 0
    Picture1.Scale (0, 2)-(30, -2)
    Picture1.Line (0, 0)-(30, 0)
    For x = 0 To t Step 1 / fs
        y = 1
        Picture1.Line (f0 * x, y)-(f0 * x, 0)
        a(n) = y
        n = n + 1
Next x

ElseIf (Option3.Value = True) Then
    For j = 0 To 1000
        a(j) = 0
    Next
    i = 0
    Picture1.Cls
    n = 0
    Picture1.Scale (0, 2)-(30, -2)
    Picture1.Line (0, 0)-(30, 0)
    For x = 0 To t Step 1 / fs
        y = 2 ^ (-x)
        Picture1.Line (f0 * x, y)-(f0 * x, 0)
        a(n) = y
        n = n + 1
Next x
End If
End Sub

Private Sub Command2_Click()
Dim x, y
If (Option1.Value = True) Then
    For j = -500 To 500
        b(j) = 0
    Next
    n = 0
    Picture2.Cls
    Picture2.Scale (0, 2)-(30, -2)
    Picture2.Line (0, 0)-(30, 0)
    For x = 0 To t Step 1 / fs
        y = Sin(f0 * x)
        Picture2.Line (x, y)-(x, 0)
        b(n) = y
        n = n + 1
    Next x

ElseIf (Option2.Value = True) Then
    For j = -500 To 500
        b(j) = 0
    Next
    n = 0
    Picture2.Cls
    Picture2.Scale (0, 2)-(30, -2)
    Picture2.Line (0, 0)-(30, 0)
    For x = 0 To t Step 1 / fs
        y = 1
        Picture2.Line (f0 * x, y)-(f0 * x, 0)
        b(n) = y
        n = n + 1
    Next x

ElseIf (Option3.Value = True) Then
    For j = -500 To 500
        b(j) = 0
    Next
    n = 0
    Picture2.Cls
    Picture2.Scale (0, 2)-(30, -2)
    Picture2.Line (0, 0)-(30, 0)
    For x = 0 To t Step 1 / fs
        y = 2 ^ (-x)
        Picture2.Line (f0 * x, y)-(f0 * x, 0)
        b(n) = y
        n = n + 1
    Next x
End If
End Sub

Private Sub Command3_Click()
Picture3.Cls
Picture3.Scale (0, 50)-(30, -50)
Picture3.Line (0, 0)-(30, 0)
For i = 0 To n
    s = 0
    For m = 0 To i
        s = s + a(m) * b(i - m)
    Next m
    Picture3.Line (i / fs, s)-(i / fs, 0), RGB(0, 0, 255)
Next i

For i = 0 To n
  s = 0
  For m = 0 To i
  s = s + a(n - i + m) * b(n - m)
  Next m
  Picture3.Line (n / fs + (n - m) / fs, s)-(n / fs + (n - m) / fs, 0), RGB(0, 0, 255)
Next i
End Sub

Private Sub Form_Load()
f0 = Val(Text1.Text)
t = Val(Text2.Text)
fs = Val(Text3.Text)
End Sub

Private Sub Text1_Change()
f0 = Val(Text1.Text)
End Sub

Private Sub Text2_Change()
t = Val(Text2.Text)
End Sub

Private Sub Text3_Change()
fs = Val(Text3.Text)
End Sub

⌨️ 快捷键说明

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