数値のバイナリ配列への変換方法を教えてください
Afficher commentaires plus anciens
次の処理を考えていますが、バイナリ配列への変換方法(②)がわかりません。どのように処理すればいいでしょうか?
①数値データのバイト順を変換する《swapbytes》。 ②4バイトのバイナリデータとして、変数に格納する。
例えば、数値「1403110」を「3865580800」に変換し、「header」という変数に4バイトのバイナリデータとして格納(追記)したいです。.NETのGetBytes関数のような、一度に変換する方法などあればご教示ください。
01行>header = double('RIFF'); %headerに「RIFF」を格納する
02行>fileSize=1403110; %数値「1403110」を定義する
03行>xFileSize = swapbytes(fileSize); %「1403110」のバイト順を変換し、「3865580800」にする
04行>header = horzcat(wavHeader, xFileSize); %headerにバイト順を変換した数値を4byteで格納する
期待する結果: header = [82 73 70 70 230 104 21 0](ASCIIのdecimal表示)
上記を実行した結果:header = [82 73 70 70 3865580800]
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur ビット単位の演算 dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!