Why does the same data occupy different sizes in different storage methods in the .mat file?
5 次查看(过去 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:
- Why are the three methods stored as .mat files different in size?
- 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?
- Use the third method to store, it is clearly 9 rows and 3 columns, why display 1x9 struct instead of 9x1 struct?
- How to change the .mat file stored in the above two ways to the third?
Any help would be much appreciated.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/363025/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/363028/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/363031/image.png)
1 个评论
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
2020-9-22
Hi,
- 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'.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 LabVIEW 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!