通过对Python模块块进行编码,我在GNURadio中创建了自己的信号源块。 现在我的目标是在几秒钟或几毫秒后自动改变它的FFT。你知道吗
我对信号源块进行编码的方式是,在不同的伪随机数下,为输出项分配不同的频率,我使用了for loop。但问题是,FFT图仅在遇到work()函数中的“return”语句时显示。在到达“返回”时间之前,所有的迭代都已经完成,因此只产生最后一次迭代的频率,因此在FFT图中只显示与最后一次生成的伪随机码对应的频率(这是不需要的)。你知道吗
长话短说,我想以某种方式显示for循环每次迭代的输出,但“return”语句不允许我这样做。它只返回最后的迭代频率。你知道吗
work(self, input_items, output_items)
.
.
local_fs =4096
SINTAB= empty([len(output_items[0])])
SINTAB = np.zeros((4096),dtype=complex)
for i in range(0,len(output_items[0])-1):
SINTAB[i]= math.sin(2*3.14*(i)/local_fs)-1j*math.cos(2*3.14*(i)/local_fs)
for f_local_index in range( 0 , 7):
check = sub_seed_hop_freq[f_local_index]
if check==1:
Freq = 0.5e6;
elif check==2:
Freq = 1e6;
elif check==3:
Freq = 1.5e6;
payload_transmitted_at = Freq
.
. (payload_step is assigned values in if else statements depending
upon the corresponding frequencies in above if else )
.
for i in range (0 , len(output_items[0])-1):
#print(len(output_items[0])-1)
output_items[0][i] = SINTAB[int(round(index_f))]
#local_I_mega_sub_seed(i) = COSTAB(round(index_f));
index_f = index_f + payload_step
#print(payload_step)
if index_f>len(output_items[0])-1:
index_f = index_f - len(output_items[0])
return len(output_items[0])
Rest是将Freq转换成正弦波的代码(由于长度的原因不能放进去) sub\u seed\u hop\u freq是随机数的向量(伪随机)
目前没有回答
相关问题 更多 >
编程相关推荐