我想將我的配置頭的某個位設置爲1(字節10的位3),如果它不是1的話。然後我想將這個新的配置頭保存爲我的舊的。我可以設置一點好,但是我很難用我的新更新舊字節來更新我的配置標題。我希望我的新配置頭是ConfigHeader = [128; 0; 0; 0; 0; 0; 0; 0; 0; 0; 30] ;.我知道這可能是一個非常簡單的解決方案!將某個位設置爲1 matlab
ConfigHeader = [128;0;0;0;0;0;0;0;0;0;26];
ByteTen = ConfigHeader(11);
if bitget(ByteTen,3) == 0
% Set bit 3 of byte 10 to 1
bitset(ByteTen,3);
% Replace old config header with new one (bit changed to 1)
ConfigHeader = ??????
end