正弦信号的变频算法
现在我遇见这样一个问题:一个复合信号源,如何将其中的50Hz的正弦信号去除,同时添加60Hz的正弦信号,这是一个数字信号的变频问题,大家有什么可以实现的算法吗?说来讨论一下。:handshake
[ 本帖最后由 zhangnan3509 于 2007-7-30 09:03 编辑 ] 可不可以滤波去掉50,然后再加上60的
回复 #1 gladstone 的帖子
很不好意思的说,这个应该去zhangnan他们信号版块,这边懂信号处理的不多,不过也会有高手有时间过来看的,等等吧 通过傅立叶级数展开,去除50hz的级数项,添加60hz的级数项,大家认为可行吗?回复 #4 gladstone 的帖子
可以试试作FFT,令50hz谱线为零,设置60hz谱线幅值、相位为你所需要的,然后再IFFT。[ 本帖最后由 zhlong 于 2007-7-30 10:59 编辑 ]
回复 #5 zhlong 的帖子
怎么设置60HZ谱线幅值和相位呢?:loveliness:回复 #6 花如月 的帖子
:'( 谢谢大侠光临:@D我做了一个模拟程序,供大家参考。
用的是fft和ifft,没有考虑60hz的振幅和相位问题。
我的模拟程序不让传:'( ,不支持.rar
[ 本帖最后由 gladstone 于 2007-7-30 23:11 编辑 ] 原帖由 gladstone 于 2007-7-30 23:06 发表 http://www.chinavib.com/forum/images/common/back.gif
:'( 谢谢大侠光临:@D
我做了一个模拟程序,供大家参考。
用的是fft和ifft,没有考虑60hz的振幅和相位问题。
我的模拟程序不让传:'( ,不支持.rar
不支持rar。但是你可以将其改为。doc然后上传。
程序代码如下
Dim K As Long, N As LongDim Ni() As Single '信号源序列
Dim Xz() As Single '信号修正序列
Dim Xs() As Single, Xx() As Single '傅立叶变换序列fft ,Xs是实部,Xx是虚部。
Dim Xns() As Single, Xnx() As Single '傅立叶逆变换序列ifft,Xns是实部,Xnx是虚部。
Dim Nimax As Single, Nimin As Single, Xnmax As Single, Xnmin As Single
Private Sub NiInit()'{Ni()}序列初始化,即信号源序列
For i = 1 To K
If Option1.Value = True Then
Ni(i) = Sin((2 * 3.1415926 * 50) / N * i) '{Ni}为50hz正弦函数离散序列
Randomize
Ni(i) = Ni(i) + Text3 - 2 * Val(Text3) * Rnd '将rnd代换为Sqr(-2 * (Log(Rnd))) * Cos(2 * 3.1415926 * Rnd)后加的是正态噪音
If i = 1 Then
Nimax = Ni(i)
Nimin = Ni(i)
Else
If Nimax < Ni(i) Then Nimax = Ni(i)
If Nimin > Ni(i) Then Nimin = Ni(i)
End If
Else
Ni(i) = Sin((2 * 3.1415926 * 50) / N * i) + Sin((2 * 3.1415926 * 120) / N * i) '{Ni}为50hz正弦函数离散序列
Randomize
Ni(i) = Ni(i) + Text3 - 2 * Val(Text3) * Rnd '将rnd代换为Sqr(-2 * (Log(Rnd))) * Cos(2 * 3.1415926 * Rnd)后加的是正态噪音
If i = 1 Then
Nimax = Ni(i)
Nimin = Ni(i)
Else
If Nimax < Ni(i) Then Nimax = Ni(i)
If Nimin > Ni(i) Then Nimin = Ni(i)
End If
End If
Next
End Sub
Private Sub XzInit()'修正50hz为60hz信号
For i = 1 To K
Xz(i) = Sin((2 * 3.1415926 * 60) / N * i) - Sin((2 * 3.1415926 * 50) / N * i)
Next
End Sub
Private Sub XInit()
For t = 1 To K
Xs(t) = 0
Xx(t) = 0
For i = 1 To K
Xs(t) = Xs(t) + Ni(i) * Cos(2 * 3.1415926 * (t - 1) * (i - 1) / K)
Xx(t) = Xx(t) - Ni(i) * Sin(2 * 3.1415926 * (t - 1) * (i - 1) / K)
Next
Next
For t = 1 To K
For i = 1 To K
Xs(t) = Xs(t) + Xz(i) * Cos(2 * 3.1415926 * (t - 1) * (i - 1) / K)
Xx(t) = Xx(t) - Xz(i) * Sin(2 * 3.1415926 * (t - 1) * (i - 1) / K)
Next
Next
End Sub
Private Sub XnInit()
For i = 1 To K
Xns(i) = 0
Xnx(i) = 0
For t = 1 To K
Xns(i) = Xns(i) + Xs(t) * Cos(2 * 3.1415926 * (t - 1) * (i - 1) / K) - Xx(t) * Sin(2 * 3.1415926 * (t - 1) * (i - 1) / K)
Xnx(i) = Xnx(i) + Xs(t) * Sin(2 * 3.1415926 * (t - 1) * (i - 1) / K) + Xx(t) * Cos(2 * 3.1415926 * (t - 1) * (i - 1) / K)
Next
Xns(i) = Xns(i) / K
If i = 1 Then
Xnmax = Xns(i)
Xnmin = Xns(i)
Else
If Xnmax < Xns(i) Then Xnmax = Xns(i)
If Xnmin > Xns(i) Then Xnmin = Xns(i)
End If
Next
End Sub
Private Sub Com_bp_Click()
XzInit
XInit
XnInit
If Nimax < 0 Then
Nimax = 0
Else
Nimax = Nimax * 1.1
End If
If Nimin > 0 Then
Nimin = 0
Else
Nimin = Nimin * 1.1
End If
Pic1.Scale (0, Nimax)-(K + 2, Nimin)
Pic1.CurrentX = 1
Pic1.CurrentY = Ni(1)
For i = 2 To K
Pic1.Line -(i + 1, Ni(i))
Next
For i = 1 To K
Pic1.Circle (i + 1, Ni(i)), 0.2, vbRed
Next
'''''''''''''''''''''''''''''''''
If Xnmax < 0 Then
Xnmax = 0
Else
Xnmax = Xnmax * 1.1
End If
If Xnmin > 0 Then
Xnmin = 0
Else
Xnmin = Xnmin * 1.1
End If
Pic2.Scale (0, Xnmax)-(K + 2, Xnmin)
Pic2.CurrentX = 1
Pic2.CurrentY = Xns(1)
For i = 2 To K
Pic2.Line -(i + 1, Xns(i))
Next
For i = 1 To K
Pic2.Circle (i + 1, Xns(i)), 0.2, vbRed
Next
End Sub
Private Sub Com_csh_Click()
K = Text1
N = Text2
ReDim Ni(K), Xz(K), Xs(K), Xns(K), Xx(K), Xnx(K)
NiInit
XzInit
End Sub
Private Sub Comm_cp_Click()
Pic1.Cls
Pic2.Cls
End Sub
Private Sub Form_Load()
Com_csh_Click
Option1.Value = True
End Sub
Private Sub Option1_Click()
Option1.Value = True
Option2.Value = False
End Sub
Private Sub Option2_Click()
Option2.Value = True
Option1.Value = False
End Sub:victory:
页:
[1]