read I/Q data from binary file
조회 수: 19 (최근 30일)
이전 댓글 표시
1st ques: How can I read from a binary file, byte by byte?? 2nd ques: How can I read from a binary file, 2 bytes at a time??
댓글 수: 0
답변 (1개)
Walter Roberson
2014년 2월 25일
fid = fopen('YourFile.bin', 'r'); %for read
data_by_one = fread(fid, '*uint8'); %read it a byte at a time
frewind(fid); %go back to the beginning
data_by_two = fread(fid, '*uint16'); %read two bytes at a time
frewind(fid); %go back to the beginning
data_by_two_swapped = fread(fid, '*uint16', 'ieee-be'); %two bytes at a time, big-ended
fclose(fid);
The default for two-byte integers is "little-ended", where the file has PQ where in memory the value would be (256 * Q + P). Reading 'big-ended' would read bytes PQ as representing (256 * P + Q), the way that God intended ;-)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Large Files and Big Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!