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

📄 form4.frm

📁 自己编的随机信号仿真,请大家提出宝贵意见。
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form4 
   Caption         =   "协方差为C(τ)=σ^2*exp(-α|τ|)的平稳高斯过程"
   ClientHeight    =   6780
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   7815
   LinkTopic       =   "Form4"
   ScaleHeight     =   6780
   ScaleWidth      =   7815
   StartUpPosition =   3  '窗口缺省
   Begin VB.Frame Frame3 
      Caption         =   "功率谱密度"
      Height          =   2295
      Left            =   120
      TabIndex        =   6
      Top             =   4440
      Width           =   5775
      Begin VB.PictureBox Picture3 
         AutoRedraw      =   -1  'True
         BackColor       =   &H80000009&
         Height          =   1695
         Left            =   120
         ScaleHeight     =   1635
         ScaleWidth      =   5475
         TabIndex        =   9
         Top             =   240
         Width           =   5535
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "2π"
         Height          =   180
         Left            =   5400
         TabIndex        =   11
         Top             =   2040
         Width           =   270
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "0"
         Height          =   180
         Left            =   120
         TabIndex        =   10
         Top             =   2040
         Width           =   90
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "自相关函数R(n)"
      Height          =   1935
      Left            =   120
      TabIndex        =   5
      Top             =   2280
      Width           =   5775
      Begin VB.PictureBox Picture2 
         AutoRedraw      =   -1  'True
         BackColor       =   &H8000000E&
         Height          =   1575
         Left            =   120
         ScaleHeight     =   1515
         ScaleWidth      =   5475
         TabIndex        =   8
         Top             =   240
         Width           =   5535
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "随机过程的样本函数"
      Height          =   2055
      Left            =   120
      TabIndex        =   4
      Top             =   120
      Width           =   5775
      Begin VB.PictureBox Picture1 
         AutoRedraw      =   -1  'True
         BackColor       =   &H80000009&
         Height          =   1695
         Left            =   120
         ScaleHeight     =   1635
         ScaleWidth      =   5475
         TabIndex        =   7
         Top             =   240
         Width           =   5535
      End
   End
   Begin VB.CommandButton Command4 
      Caption         =   "返回"
      Height          =   495
      Left            =   6000
      TabIndex        =   3
      Top             =   5880
      Width           =   1455
   End
   Begin VB.CommandButton Command3 
      Caption         =   "估算功率谱密度"
      Enabled         =   0   'False
      Height          =   495
      Left            =   6000
      TabIndex        =   2
      Top             =   4680
      Width           =   1455
   End
   Begin VB.CommandButton Command1 
      Caption         =   "产生样本函数"
      Height          =   495
      Left            =   6000
      TabIndex        =   1
      Top             =   360
      Width           =   1455
   End
   Begin VB.CommandButton Command2 
      Caption         =   "产生自相关函数"
      Enabled         =   0   'False
      Height          =   495
      Left            =   6000
      TabIndex        =   0
      Top             =   2520
      Width           =   1455
   End
End
Attribute VB_Name = "Form4"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i, j, mean, var, y(0 To 99), yr(0 To 99), yi(0 To 99), x(0 To 99), r(0 To 250), max As Double
  Const PI = 3.1415926
Private Sub Command1_Click()
  Picture1.Cls
  Picture1.Scale (0, 3)-(50, -3)
  Picture1.Line (0, 0)-(50, 0)
  Picture1.Line (0, -1)-(50, -1)
  Picture1.Line (0, 1)-(50, 1)
  Randomize 1024
     x(0) = Sqr(-2 * Log(Rnd(256)) / Log(10)) * Sin(2 * PI * Rnd(256))
     y(0) = x(0)
     Picture1.Circle (1, y(0)), 0.5, RGB(10, 10, 255)
    For i = 1 To 50
          x(i) = Sqr(-2 * Log(Rnd(256) / Log(10))) * Sin(2 * PI * Rnd(256))
          y(i) = Exp(-1) * y(i - 1) + Sqr(1 - Exp(-2)) * x(i)
          Picture1.Line (i - 1, y(i - 1))-(i, y(i)), RGB(225, 0, 0)
          Picture1.Circle (i, y(i)), 0.5, RGB(10, 10, 255)
    Next i
 Command2.Enabled = True
End Sub

Private Sub Command2_Click()
  Picture2.Cls
  Picture2.Scale (-50, 3)-(50, -3)
  Picture2.Line (-50, 0)-(50, 0)
  Picture2.Line (0, 0)-(0, 3)
  For i = 0 To 50
     r(i) = 0
  Next i
  mean = 0
  For i = 1 To 50
     For j = 0 To 50 - i - 1
         mean = mean + x(j) * x(j + i)
     Next j
     r(i) = mean / 50
     Picture2.Line (i, 0)-(i, r(i)), RGB(225, 0, 0)
     Picture2.Circle (i, r(i)), 0.5, RGB(10, 10, 255)
     Picture2.Line (-1 * i, 0)-(-1 * i, r(i)), RGB(225, 0, 0)
     Picture2.Circle (-1 * i, r(i)), 0.5, RGB(10, 10, 255)
  Next i
  Command3.Enabled = True
End Sub

Private Sub Command3_Click()
  Picture3.Cls
  Picture3.Scale (-50, 1)-(50, -2)
  For i = 1 To 50
     yr(i) = 0
     yi(i) = 0
     For j = 1 To i
       yr(i) = yr(i) + y(j) * Cos(2 * PI * i * j / 50)
       yi(i) = yi(i) + y(j) * Sin(2 * PI * i * j / 50)
     Next j
     yr(i) = Sqr((yr(i) * yr(i) + yi(i) * yi(i)))
     x(i) = Log(yr(i) / i) / Log(10)
 Next i
     Picture3.Circle (0, x(1)), 0.5, RGB(10, 10, 255)
 For i = 2 To 50
     Picture3.Line (i - 2, x(i - 1))-(i - 1, x(i)), RGB(225, 0, 0)
     Picture3.Circle (i - 1, x(i)), 0.5, RGB(10, 10, 255)
     Picture3.Line (-1 * (i - 2), x(i - 1))-(-1 * i + 1, x(i)), RGB(225, 0, 0)
     Picture3.Circle (-1 * i + 1, x(i)), 0.5, RGB(10, 10, 255)
 Next i
End Sub

Private Sub Command4_Click()
Form4.Visible = False
Form1.Visible = True
End Sub

⌨️ 快捷键说明

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