Why does the same data occupy different sizes in different storage methods in the .mat file?

11 visualizaciones (últimos 30 días)
Hello!
I found some problems in storing the data as a .mat format file and importing it into LabVIEW NXG. The same data uses the following three different storage methods to occupy different sizes in .mat files. The storage size gap is especially obvious when the amount of data is large, for example: 600000x50 or 50x600000.
Below are three screenshots. In the first screenshot, each column is a field and takes up minimal storage space. In the second screenshot, each row is a field and takes up more storage space than the first method. In the third screenshot, each column is a field and the field name is marked, which takes up the most storage space. I have the following questions:
  1. Why are the three methods stored as .mat files different in size?
  2. Import the .mat files into other software such as LabVIEW NXG. Regardless of the first or second storage method, why the software defaults to each row is a field?
  3. Use the third method to store, it is clearly 9 rows and 3 columns, why display 1x9 struct instead of 9x1 struct?
  4. How to change the .mat file stored in the above two ways to the third?
Any help would be much appreciated.
  1 comentario
Mohammad Sami
Mohammad Sami el 20 de Sept. de 2020
Editada: Mohammad Sami el 20 de Sept. de 2020
The reason why the saved data is different size is because internally it's organized differently. Due to this the final size after compression is different.

Iniciar sesión para comentar.

Respuestas (1)

Gaurav Garg
Gaurav Garg el 22 de Sept. de 2020
Hi,
  1. The reason behind three .mat files being stored in different sizes is -
MATLAB saves mat files after compressing the data and encoding Unicode characters.
Moreover, it depends on MATLAB version too. You can select this option in Preference=>General=>MAT-Files.
2. MATLAB stores data in column-major order. This can be one reason why your software defaults to each row as a field.
3. For the structure 'a', you have 3 columns/fields named 'a1', 'a2' and 'a3', and 9 rows represent 9 structures.
4. You can write a loop traversing all the elements of arrays in 1st and 2nd method and store the values in structure 's'.
For more information on structures in MATLAB, you can look at the documentation.

Categorías

Más información sobre Low-Level File I/O en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by