Read binary file 3 bytes at a time
古いコメントを表示
Hi, I am new and I discovered that the fread by default reads a binary file 1 byte at a time, how can I read the file 3 bytes at a time. Thanks
採用された回答
その他の回答 (2 件)
Guillaume
2015 年 6 月 10 日
A much simpler solution would have been to read the file with a precision of 'ubit24' (or 'bit24' if the integer are signed), which is basically a 3 byte integer:
x = fread(fid, 'ubit24'); %that's it. all done
1 件のコメント
James Tursa
2015 年 6 月 11 日
Good one ... I learned something today about formats available for fread.
Walter Roberson
2015 年 6 月 10 日
fread(fid, 3)
4 件のコメント
Domenico Bellantoni
2015 年 6 月 10 日
Domenico Bellantoni
2015 年 6 月 10 日
James Tursa
2015 年 6 月 10 日
編集済み: James Tursa
2015 年 6 月 10 日
Do you mean you have a file of many bytes, and each group of 3 bytes in the file should be read in as an individual number? If so, what type of number? An integer of some sort?
Domenico Bellantoni
2015 年 6 月 10 日
編集済み: Domenico Bellantoni
2015 年 6 月 10 日
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!