すべての数値の最後の 3 ビットを反転する必要がある uint16 ベクトルがあります。
私はすでにこれを行っていますが、これを行うためのより簡単な解決策が必要だと思います。これが私のコードです。
%Turn the vector to binary
V_bin = dec2bin(V,16);
for i=1:length(V)
%Get the last 3 bits
tmp = V_bin(14:end);
%Convert the string to decimal
tmpdec = bin2dec(tmp);
%Do the flip
tmpflip = bitcmp(uint8(tmpdec));
%Flipped to binary
tmpbin = dec2bin(tmpflip);
%Replace the flipped bits in the original string
V_bin(14:end) = tmpbin(6:end);
end
V = bin2dec(V_bin);
ご覧のとおり、単純な操作には多くの行がありますが、同じことを行うためのより効率的な方法があるのではないかと思います。