How do I read in specific parts of a binary file?

조회 수: 11 (최근 30일)
Kalamaya
Kalamaya 2012년 5월 9일
Hi all,
I would like to simply read in a specific, pre-determined length of a binary file in MATLAB. The file is huge, and I cannot/don't want to simply read all of it at once.
I have looked at the 'skip' command within fread but I do not want to skip chunks, I just have one chunk that I want to read in, and be done with it.
How can this be done? (The file is an int16 .bin file).
For example: My file has 1e6 samples, and it int16. I want to ONLY read in the values from sample, say, 433,232, up to, 546,323. How can this be done?
Thanks
  댓글 수: 1
per isakson
per isakson 2012년 5월 9일
I think it can be done with memmapfile, but I haven't tried.

댓글을 달려면 로그인하십시오.

채택된 답변

Oleg Komarov
Oleg Komarov 2012년 5월 9일
Use fseek and then fread.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 5월 9일
fseek(fid, OFFSET, 'bof')
OFFSET would start at 0 for the first byte of the file.

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by