📄 frmfft2.frm
字号:
VERSION 5.00
Begin VB.Form frmFFT
BackColor = &H8000000B&
Caption = "FFT"
ClientHeight = 4680
ClientLeft = 60
ClientTop = 345
ClientWidth = 8880
LinkTopic = "Form1"
ScaleHeight = 4680
ScaleWidth = 8880
StartUpPosition = 3 'Windows Default
Begin VB.PictureBox Picture2
Height = 3015
Left = 1200
ScaleHeight = 2955
ScaleWidth = 7155
TabIndex = 11
Top = 480
Width = 7215
End
Begin VB.PictureBox Picture1
AutoRedraw = -1 'True
BackColor = &H80000009&
Height = 1365
Left = 480
ScaleHeight = 1305
ScaleWidth = 3795
TabIndex = 10
Top = 360
Width = 3855
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 375
Left = 4680
TabIndex = 9
Top = 4080
Width = 1455
End
Begin VB.TextBox Text1
Height = 375
Left = 2880
TabIndex = 8
Text = "1"
Top = 4080
Width = 1455
End
Begin VB.PictureBox PicBox2
BackColor = &H80000009&
Height = 1575
Index = 1
Left = 4680
ScaleHeight = 1515
ScaleWidth = 3795
TabIndex = 5
Top = 2280
Width = 3855
End
Begin VB.PictureBox PicBox
BackColor = &H80000009&
Height = 1335
Index = 1
Left = 4680
ScaleHeight = 1275
ScaleWidth = 3795
TabIndex = 4
Top = 360
Width = 3855
End
Begin VB.PictureBox PicBox2
BackColor = &H80000009&
Height = 1575
Index = 0
Left = 480
ScaleHeight = 1515
ScaleWidth = 3795
TabIndex = 1
Top = 2280
Width = 3855
End
Begin VB.PictureBox PicBox
BackColor = &H80000009&
Height = 1335
Index = 0
Left = 480
ScaleHeight = 1275
ScaleWidth = 3795
TabIndex = 0
Top = 360
Visible = 0 'False
Width = 3855
End
Begin VB.Label Label2
Caption = "FFT(寢壥2)"
Height = 255
Index = 1
Left = 4800
TabIndex = 7
Top = 2040
Width = 975
End
Begin VB.Label Label1
Caption = "僨乕僞(2)"
Height = 255
Index = 1
Left = 4920
TabIndex = 6
Top = 120
Width = 735
End
Begin VB.Label Label2
Caption = "FFT(寢壥1)"
Height = 255
Index = 0
Left = 720
TabIndex = 3
Top = 1920
Width = 975
End
Begin VB.Label Label1
Caption = "僨乕僞(1)"
Height = 255
Index = 0
Left = 720
TabIndex = 2
Top = 120
Width = 735
End
End
Attribute VB_Name = "frmFFT"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim jj As Integer
Dim N As Integer
Dim x() As Double, y() As Double
Private Sub Command1_Click()
PicBox2(0).Cls
PicBox2(1).Cls
Visible = True: AutoRedraw = True
Width = 9000: Height = 5000
Dim pi As Double
pi = 4 * Atn(1)
N = 256
ReDim x(N) As Double, y(N) As Double
frmSinWave2 x(), y(), N
fftMain Me.PicBox(0), Me.PicBox2(0), x(), y(), N, 0
frmStep x(), y(), N
fftMain Me.PicBox(1), Me.PicBox2(1), x(), y(), N, 0
End Sub
Private Sub Form_Load()
Visible = True: AutoRedraw = True
Width = 9000: Height = 5000
Dim pi As Double
pi = 4 * Atn(1)
N = 256
ReDim x(N) As Double, y(N) As Double
frmSinWave2 x(), y(), N
fftMain Me.PicBox(0), Me.PicBox2(0), x(), y(), N, 0
frmStep x(), y(), N
fftMain Me.PicBox(1), Me.PicBox2(1), x(), y(), N, 0
Picture1.DrawWidth = 1 '定义画出点的大小
Picture1.Scale (0, 200)-(9000, -200) '定义坐标
Dim sA As String '声明变量
Open "a.txt" For Input As #1 '打开文件
For jj = 0 To 9000 Step 1
Line Input #1, sA '读出一行数据
Picture1.PSet (jj, Val(sA))
Next jj
Close #1 '关闭文件
End Sub
Private Sub frmStep(x() As Double, y() As Double, N As Integer)
Dim i As Integer
For i = 1 To N
If i <= N / 2 Then
x(i) = -1
Else
x(i) = 1
End If
y(i) = 0
Next i
End Sub
Private Sub frmSinWave1(x() As Double, y() As Double, N As Integer)
Dim i As Integer, dt1 As Double, dt2 As Double, dt3 As Double
Dim pi As Double
pi = 4 * Atn(1)
dt1 = 2 * pi * 4 / N
dt2 = 2 * pi * 16 / N
dt3 = 2 * pi * 32 / N
For i = 1 To N
x(i) = Sin(dt1 * (i - 1)) + 0.5 * Sin(dt2 * (i - 1) + pi / 4) + 0.25 * Sin(dt3 * (i - 1))
y(i) = 0
Next i
End Sub
Private Sub frmSinWave2(x() As Double, y() As Double, N As Integer)
Dim i As Integer, dt1 As Double, dt2 As Double
Dim pi As Double
pi = 4 * Atn(1)
dt1 = 2 * pi * 4.4 / N
' dt2 = 2 * pi * 16 / N
For i = 1 To N
x(i) = Sin(dt1 * (i - 1)) ' + 0.5 * Sin(dt2 * (i - 1) + pi / 4)
y(i) = 0
Next i
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If (KeyAscii < Asc("0") Or KeyAscii > Asc("9")) And KeyAscii >= Asc(" ") Then
KeyAscii = 0
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -