Reading a binary file in parts

조회 수: 5 (최근 30일)
Federico
Federico 2023년 9월 24일
댓글: Federico 2023년 9월 24일
I have raw data from a sensor stored in a 1Gb binary file, and I would like to read it sequentially, i.e. in a loop, where the information is being processed simultaneously. In other words, as if the data were being received in real time. Is that possible in Matlab?

채택된 답변

Alexander
Alexander 2023년 9월 24일
You should use fread.
  댓글 수: 4
Alexander
Alexander 2023년 9월 24일
이동: Voss 2023년 9월 24일
Just some remarks:
If you are not short of memory you can use
in = fread(fid);
Than you have the whole bunch of bits and bytes in your vector "in". After that you can parse the data according your needs.
Second: If you have to deal often with the file directly, get familiar with the low level i/o functions of Matlab (i.e. fseek, frewind, feof, ..., these are similar like the functions in C language), then you can stroll through your file as you want.
Federico
Federico 2023년 9월 24일
Understood. Thanks to both of you!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by