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

6 vues (au cours des 30 derniers jours)
E
E le 21 Juil 2019
Modifié(e) : E le 21 Juil 2019
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

Réponse acceptée

Walter Roberson
Walter Roberson le 21 Juil 2019
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 commentaires
Walter Roberson
Walter Roberson le 21 Juil 2019
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 le 21 Juil 2019
Modifié(e) : E le 21 Juil 2019
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

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by