what is the difference between data chunk and buffer in matlab?

2 次查看(过去 30 天)
i want to know difference between chunk data and buffer by example
if i have a large file that i just want to read part of it each time what the differece of both
Thanks

采纳的回答

Walter Roberson
Walter Roberson 2019-7-21
MATLAB does not generally use the term "data chunk". It does occur in some contexts:
Generally speaking, a data chunk is a decoded valid subset of data, such as a certain number of rows of input. Generally speaking, a buffer is often an undecoded portion of data that might not happen to nicely align with a number of rows. For example, a "buffer" of data might happen to be exactly 8 kilobytes for I/O efficiency, and that might happen to end in the middle of a number.
  3 个评论
Walter Roberson
Walter Roberson 2019-7-21
Potentially, but it depends what you are doing. MATLAB is not strong on "stream I/O"
An example of a situation in which it is possible is any of the serial-like I/Os, whether from serial port or from udp or tcp . You can configure an input buffer, and you can configure a callback when it gets to a certain size. At that point, you can read from object, which implicitly reads from the buffer, and you can do that reading using (for example) fscanf() requesting a particular size of result, which you would have calculated as being safely within the buffer size because you know the maximum field widths for each item and so can calculate the mininum number of parseable objects in the buffer.
For files, you can fread() a fixed amount of uint8=>char for efficiency, putting it into your own buffer. Then you can textscan() from the buffer, and record both outputs; the second output tells you how much of the buffer you used up. Save off the unused part to prepend to the next chunk of data.
E
E 2019-7-21
编辑:E 2019-7-21
thanks so much
the problem for me related to read data from file as stream so i will ask another question in detail
thanks again

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by