File write in MATLAB

1 回表示 (過去 30 日間)
Harish Kumar
Harish Kumar 2011 年 7 月 27 日
Hi, I used fread (fileptr, 2048, 'bit14', 2) to read 2048 samples of 14 bit data from a file. When I tried writing the same values to an output file using fwrite (fileptr, 2048, 'bit14', 2). I see that the bytes are swapped. Can anyone help on this issue?

回答 (1 件)

Jan
Jan 2011 年 7 月 27 日
You define the byte ordering in the FOPEN command. See te machineformat argument.
  2 件のコメント
Harish Kumar
Harish Kumar 2011 年 7 月 29 日
Hi, thank you for the tip. I used the options but not sure what to use. I am using a windows PC with XP os. For windows, the machine format is 'l' (little endian). So I used the 'l' option, but it did not help.
Jan
Jan 2011 年 7 月 29 日
@Harish: Little-Endian is the default on PCs. But I assume, your original files are written in Big-Endian format. Therefore I suggest to specify Big-Endian for reading and writing the binary file.

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

カテゴリ

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