如何对两个位数组进行异或运算,以便找出使用二进制对称通道添加的错误

2024-04-28 10:40:15 发布

您现在位置:Python中文网/ 问答频道 /正文

# -*- coding: utf-8 -*-
"""
Created on Fri Feb  5 12:02:55 2021
@author: Sam
"""
'Libraries'
import komm as komm
#import numpy as np 
#from math import pi 
#import matplotlib.pyplot as plt
#import matplotlib as np

#Varibles
x = [0,1,0,0,1,1]
pam = komm.PAModulation(4, base_amplitude=1.0)      
awgn = komm.AWGNChannel(snr=100.0, signal_power=1.0) 'Noise channel'
bsc = komm.BinarySymmetricChannel(0.1)              'Binary symmetric channel'
y = awgn(x); y                                      'Adding noise to x array'
z = bsc(x); z                                       'BSC applied to x array'


#Main code:
data_tx = pam.modulate(x)
data_rx = pam.demodulate(data_tx)

#data_tx2 = pam.modulate(y)


print ('PAM modulated data is: ',data_tx)
print ('Demodulated data is:   ',data_rx)
print ('Array with noise added is: ',y)
print ('Channel capacity is: ',awgn.capacity())

print(z)


data1 = sum(XOR(x,z))

#print (pam.constellation)
#print (pam.energy_per_bit)

这是我目前拥有的代码,在第37行“data1=sum(XOR(x,z))”中,我希望能够对这两个数组进行异或。是否有一个内置的异或函数或库允许这一操作。 或者我如何设置它,只使用for循环遍历数组的每个索引


Tags: toimportdatamatplotlibisasnpchannel