Change the default data type to uint16

This commit is contained in:
Xianjun Jiao 2025-02-18 13:24:23 +01:00
parent 4cfdc1c47c
commit bd3f48f407
2 changed files with 6 additions and 4 deletions

View File

@ -56,8 +56,8 @@ def parse_iq(iq, iq_len):
timestamp = iq[:,0] + pow(2,16)*iq[:,1] + pow(2,32)*iq[:,2] + pow(2,48)*iq[:,3]
iq_capture = np.int16(iq[:,4::4]) + np.int16(iq[:,5::4])*1j
agc_gain = iq[:,6::4]
rssi_half_db = iq[:,7::4]
agc_gain = np.bitwise_and(iq[:,6::4], np.uint16(0xFF))
rssi_half_db = np.bitwise_and(iq[:,7::4], np.uint16(0x7FF))
# print(num_trans, iq_len, iq_capture.shape, agc_gain.shape, rssi_half_db.shape)
iq_capture = iq_capture.reshape([num_trans*iq_len,])

View File

@ -37,8 +37,10 @@ for i=1:num_iq_capture
ep = i*num_data_in_each_iq_capture;
timestamp(i) = double(b(sp,1)) + (2^16)*double(b(sp,2)) + (2^32)*double(b(sp,3)) + (2^48)*double(b(sp,4));
iq_capture(:,i) = double(typecast(b((sp+1):ep,1),'int16')) + 1i.*double(typecast(b((sp+1):ep,2),'int16'));
agc_gain(:,i) = double(b((sp+1):ep,3));
rssi_half_db(:,i) = double(b((sp+1):ep,4));
// agc_gain(:,i) = double(b((sp+1):ep,3));
agc_gain(:,i) = double(bitand(b((sp+1):ep,3), uint16(255)));
// rssi_half_db(:,i) = double(b((sp+1):ep,4));
rssi_half_db(:,i) = double(bitand(b((sp+1):ep,4), uint16(2047)));
end
save(['iq_' num2str(iq_len) '.mat'], 'iq_capture');