我在验证我写的一个简单的IDFT程序-
###############################################################
#My IDFT Routines
###############################################################
def simple_idft(data_f):
data_t_r = []
data_t_i = []
for ii in range(0,len(data_f)):
tmp_r=0.00
tmp_i=0.00
scale = 1.00/len(data_f)
for jj in range(0,len(data_f)):
tmp_r += data_f[jj].real*math.cos(2.00*math.pi*ii*jj/len(data_f)) - data_f[jj].imag*math.sin(2.00*math.pi*ii*jj/len(data_f))
tmp_i += data_f[jj].real*math.sin(2.00*math.pi*ii*jj/len(data_f)) + data_f[jj].imag*math.cos(2.00*math.pi*ii*jj/len(data_f))
tmp_r *=scale
tmp_i *=scale
data_t_r.append(tmp_r)
data_t_i.append(tmp_i)
return data_t_r, data_t_i
def rms_idft(data_t_r, data_t_i):
rms = []
for ii in range(0,len(data_t_r)):
rms.append(math.sqrt(data_t_r[ii]**2 + data_t_i[ii]**2))
return rms
def do_idft(data_t):
data_t_r, data_t_i = simple_idft(data_t)
rms = rms_idft(data_t_r, data_t_i)
return(rms)
与愚蠢的IDFT程序进行对比-
################################################################
#Transform OFDM Data to time domain
################################################################
def IDFT(OFDM_data):
return np.fft.ifft(OFDM_data)
当我运行这些(64点数据)时,我似乎得到了非常不同的结果-
OFDM_time = IDFT(OFDM_data)
print ("Number of OFDM samples in time-domain before CP: ", len(OFDM_time))
print(OFDM_time)
plt.plot(OFDM_time)
plt.show()
rms = []
rms = do_idft(OFDM_data)
plt.plot(rms,label='raj')
plt.legend()
plt.show()
你能看出我的算法有什么错误吗?
1条答案
按热度按时间xzv2uavs1#
好的,我发现了问题...... Numpy IDFT例程输出的绘图是错误的,而应该是-