% ==================================================
% 作者: jialf
% 时间: 2021/7/15
% 版本: V1
% =================16进制正弦波表================
Qn=12;
len=128;
t=0:len-1;
lut=round((2^(Qn-1)-1)*sin(2*pi*t/len));
for i=1:len
if lut(i)<0
lut(i) = 2^Qn +lut(i);
end
fprintf('0x%.3X, ',lut(i));
if mod(i,8)==0
fprintf('\n');
end
end
0x000, 0x064, 0x0C9, 0x12C, 0x18F, 0x1F1, 0x252, 0x2B2,
0x30F, 0x36B, 0x3C5, 0x41C, 0x471, 0x4C3, 0x513, 0x55F,
0x5A7, 0x5ED, 0x62E, 0x66C, 0x6A6, 0x6DC, 0x70D, 0x73A,
0x763, 0x787, 0x7A7, 0x7C2, 0x7D8, 0x7E9, 0x7F5, 0x7FD,
0x7FF, 0x7FD, 0x7F5, 0x7E9, 0x7D8, 0x7C2, 0x7A7, 0x787,
0x763, 0x73A, 0x70D, 0x6DC, 0x6A6, 0x66C, 0x62E, 0x5ED,
0x5A7, 0x55F, 0x513, 0x4C3, 0x471, 0x41C, 0x3C5, 0x36B,
0x30F, 0x2B2, 0x252, 0x1F1, 0x18F, 0x12C, 0x0C9, 0x064,
0x000, 0xF9C, 0xF37, 0xED4, 0xE71, 0xE0F, 0xDAE, 0xD4E,
0xCF1, 0xC95, 0xC3B, 0xBE4, 0xB8F, 0xB3D, 0xAED, 0xAA1,
0xA59, 0xA13, 0x9D2, 0x994, 0x95A, 0x924, 0x8F3, 0x8C6,
0x89D, 0x879, 0x859, 0x83E, 0x828, 0x817, 0x80B, 0x803,
0x801, 0x803, 0x80B, 0x817, 0x828, 0x83E, 0x859, 0x879,
0x89D, 0x8C6, 0x8F3, 0x924, 0x95A, 0x994, 0x9D2, 0xA13,
0xA59, 0xAA1, 0xAED, 0xB3D, 0xB8F, 0xBE4, 0xC3B, 0xC95,
0xCF1, 0xD4E, 0xDAE, 0xE0F, 0xE71, 0xED4, 0xF37, 0xF9C,
通过Qn可以指定16进制数据的大小范围,len可以指定表的长度。非常的方便。