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

조회 수: 9 (최근 30일)
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
Mohammad Sami
Mohammad Sami 2020년 9월 20일
편집: Mohammad Sami 2020년 9월 20일
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.

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

답변 (1개)

Gaurav Garg
Gaurav Garg 2020년 9월 22일
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.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by