我试着验证我写的一个简单的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()

你能看到我算法中的错误吗?
发布于 2022-11-12 16:05:39
好吧我发现了问题..。Numpy IDFT例程输出的绘制是错误的,而应该是-
################################################################
#Transform OFDM Data to time domain
################################################################
def IDFT(OFDM_data):
return np.fft.ifft(absOFDM_data)
OFDM_time = IDFT(OFDM_data)
print ("Number of OFDM samples in time-domain before CP: ", len(OFDM_time))
print(OFDM_time)
plt.plot(abs(OFDM_time)) **##need to take the absolute val**
plt.show()

https://stackoverflow.com/questions/74409694
复制相似问题