C言語のunsigned charをmatlabコードに変換しようとしていますが、unsigned charのベクトルは16進値で埋められています。私は同じことを行うために作成Cのunsigned charをMatLabに変換する
int main()
{
unsigned char value = 0xaa;
signed char temp;
// cast to signed value
temp = (signed char) value;
// if MSB is 1, then this will signed extend and fill the temp variable with 1's
temp = temp >> 7;
// AND with the reduction variable
temp = temp & 0x1b;
// finally shift and reduce the value
printf("%u",((value << 1)^temp));
}
MATLAB関数:Cコードの下には
value = '0xaa';
temp = int8(value);
temp2 = int8(value);
temp = bitsra(temp,7);
temp = and(temp,'0x1b');
galois_value = xor(bitsll(temp2,1),temp);
disp(galois_value);
印刷の値は、各コードが異なっている、誰かが何が起こっているか知っていますか?
注意を、あなたのCコードは処理系定義の動作に依存しています。 –
これは問題ではないが、CコードはTexas InstrumentsのライブラリでMSP430で使用することができます。シリーズMCUパフォーマンスを比較するためにMatLabにCコードを実装する必要があります。そのため、私はCコードを変更できません。 –