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 CenterFile Exchange에서 Low-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