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

📄 随机试验coco.frm

📁 随机信号课程的实验
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   9495
   ClientLeft      =   2340
   ClientTop       =   915
   ClientWidth     =   10905
   LinkTopic       =   "Form1"
   ScaleHeight     =   9495
   ScaleWidth      =   10905
   Begin VB.CommandButton Command5 
      Caption         =   "随机数生成(b)"
      Height          =   855
      Left            =   5280
      TabIndex        =   18
      Top             =   2760
      Width           =   1095
   End
   Begin VB.PictureBox Picture4 
      Height          =   1815
      Left            =   6480
      ScaleHeight     =   1755
      ScaleWidth      =   4155
      TabIndex        =   17
      Top             =   1680
      Width           =   4215
   End
   Begin VB.CommandButton Command4 
      Caption         =   "功率谱"
      Height          =   735
      Left            =   1440
      TabIndex        =   15
      Top             =   7560
      Width           =   1455
   End
   Begin VB.CommandButton Command3 
      Caption         =   "自相关函数"
      Height          =   735
      Left            =   1320
      TabIndex        =   14
      Top             =   4680
      Width           =   1455
   End
   Begin VB.PictureBox Picture3 
      Height          =   2055
      Left            =   3360
      ScaleHeight     =   1995
      ScaleWidth      =   6555
      TabIndex        =   13
      Top             =   6960
      Width           =   6615
   End
   Begin VB.PictureBox Picture2 
      Height          =   2055
      Left            =   3360
      ScaleHeight     =   1995
      ScaleWidth      =   6555
      TabIndex        =   12
      Top             =   4200
      Width           =   6615
   End
   Begin VB.TextBox Text3 
      Height          =   495
      Left            =   5400
      TabIndex        =   5
      Text            =   "1024"
      Top             =   120
      Width           =   1215
   End
   Begin VB.TextBox Text2 
      Height          =   495
      Left            =   3600
      TabIndex        =   4
      Text            =   "1"
      Top             =   600
      Width           =   1215
   End
   Begin VB.TextBox Text1 
      Height          =   495
      Left            =   3600
      TabIndex        =   3
      Text            =   "0"
      Top             =   120
      Width           =   1215
   End
   Begin VB.CommandButton Command2 
      BackColor       =   &H80000001&
      Caption         =   "结束"
      Height          =   1095
      Left            =   8400
      TabIndex        =   2
      Top             =   240
      Width           =   1215
   End
   Begin VB.PictureBox Picture1 
      Height          =   2055
      Left            =   1320
      ScaleHeight     =   1995
      ScaleWidth      =   3435
      TabIndex        =   1
      Top             =   1560
      Width           =   3495
   End
   Begin VB.CommandButton Command1 
      Caption         =   "随机数生成(a)"
      Height          =   855
      Left            =   240
      TabIndex        =   0
      Top             =   2760
      Width           =   975
   End
   Begin VB.Label Label9 
      Caption         =   "均值为0,方差为1"
      Height          =   735
      Left            =   5280
      TabIndex        =   20
      Top             =   2280
      Width           =   1215
   End
   Begin VB.Label Label8 
      Caption         =   "任意均值方差"
      Height          =   855
      Left            =   360
      TabIndex        =   19
      Top             =   2160
      Width           =   975
   End
   Begin VB.Label Label7 
      Caption         =   "随机数的参数设定"
      Height          =   615
      Left            =   960
      TabIndex        =   16
      Top             =   600
      Width           =   1455
   End
   Begin VB.Label Label6 
      Caption         =   "x"
      Height          =   495
      Left            =   4680
      TabIndex        =   11
      Top             =   3600
      Width           =   1215
   End
   Begin VB.Label Label5 
      Caption         =   "y"
      Height          =   495
      Left            =   1080
      TabIndex        =   10
      Top             =   1560
      Width           =   1215
   End
   Begin VB.Label Label4 
      Caption         =   "0"
      Height          =   255
      Left            =   1080
      TabIndex        =   9
      Top             =   3720
      Width           =   495
   End
   Begin VB.Label Label3 
      Caption         =   "个数 "
      Height          =   495
      Left            =   4920
      TabIndex        =   8
      Top             =   240
      Width           =   1215
   End
   Begin VB.Label Label2 
      Caption         =   "末值 "
      Height          =   495
      Left            =   2760
      TabIndex        =   7
      Top             =   840
      Width           =   1215
   End
   Begin VB.Label Label1 
      Caption         =   "初值 "
      Height          =   375
      Left            =   2760
      TabIndex        =   6
      Top             =   240
      Width           =   855
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Const N As Integer = 1024
Const pi As Single = 3.141593
Dim x(0 To N - 1), r(-100 To 100) As Single
Private Sub Command1_Click()
Picture1.Cls
Picture4.Cls
Dim a%, i%, l1%, l2%
Dim c As Double
Randomize
a = Text3.Text
l1 = Text1.Text
l2 = Text2.Text
Label5.Caption = 1.5 * l2
Label6.Caption = a
For i = 0 To a - 1
 x(i) = l1 + (l2 - l1) * Rnd
 Next i
 Picture1.Scale (0, 1.5 * l2)-(a, 0)
 For i = 0 To a - 1
  Picture1.PSet (i, x(i)), vbRed
  Next i
End Sub

Private Sub Command5_Click()
Picture4.Cls
Dim a, Deviation, Mean, i As Integer
a = 1: Mean = 0: Deviation = 1
Randomize
For i = 0 To N - 1
    x(i) = Deviation * Sqr(-2 * Log(Rnd)) * Cos(2 * pi * Rnd) + Mean
Next
Picture1.Picture = LoadPicture()
Picture4.Scale (0, 5)-(N, -5)
x(0) = Deviation * x(0): Picture4.PSet (0, x(0)), vbRed
For i = 1 To N - 1
    x(i) = Exp(-a) * x(i - 1) + Deviation * Sqr(1 - Exp(-2 * a)) * x(i)
    Picture4.PSet (i, x(i)), vbRed
Next
End Sub


Private Sub Command2_Click()
End
End Sub

Private Sub Command3_Click()
Dim m, i As Integer
Picture2.Picture = LoadPicture()
Picture2.Scale (-100, 1.1)-(100, -0.2)
For m = -100 To 100 Step 1
    r(m) = 0
    For i = 0 To N - Abs(m) - 1
        r(m) = r(m) + x(i) * x(i + Abs(m)) / N
    Next
    Picture2.Line (m, 0)-(m, r(m)), vbRed
Next
Command3.Enabled = True
End Sub

Private Sub Command4_Click()
Dim sr, si, w As Single, i As Integer
Picture3.Picture = LoadPicture()
Picture3.Scale (0, 7)-(2 * pi, 0)
For w = 0 To 2 * pi Step 0.001
    sr = 0: si = 0
    For i = -100 To 100
        sr = sr + r(i) * Cos(w * i): si = si + r(i) * Sin(-1 * w * i)
    Next
    Picture3.PSet (w, Sqr(sr * sr + si * si)), vbRed
Next
End Sub


⌨️ 快捷键说明

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