Binary file read 16bit word in 2's complement

4 ビュー (過去 30 日間)
Francisco Dias
Francisco Dias 2017 年 10 月 30 日
コメント済み: Francisco Dias 2017 年 10 月 30 日
Hi everyone, I have a binary file and I'm trying to read 16bit words (values) in 2's complement (till the end of the file). Is this something that can be done with default Matlab functions 'fread'?! Or must I use some other technique (custom functions).

採用された回答

Jan
Jan 2017 年 10 月 30 日
What happens if you simply try it with fread? Post the code and explain the remaining problems specifically.
  1 件のコメント
Francisco Dias
Francisco Dias 2017 年 10 月 30 日
raw_file = fopen([filename '.r' num2str(channels) 'a']);
raw_data = fread(raw_file, Inf, 'int16');
this is the code and while it works (well, it reads the file) I don't know if I'm reading it right.. this is a binary file from an EEG device.. so I don't know the values upfront to compare them. The device manual says:
"Each sample is a 16-bit word in 2's complement form."
This is all I have!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLow-Level File I/O についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by