save function significantly larger than variables in the file
조회 수: 19 (최근 30일)
이전 댓글 표시
I'm using R2018b running on a linux (CentOS 7) machine.
I have a structure X that is about 400MB in size inside matlab (according to the size listed in "Workspace"). If I save that variable to a .mat file, e.g.:
> save('MyStructure.mat','X')
The resulting .mat file is about 1.3Gb in size, or 3X larger than the size of the variable it is saving. Looking at my preferences, the default save format is V7.3.
However, if I save the same variable using the V7 format
> save('MyStructure.V7.mat','X','-v7')
The resulting .mat file is now only about 12MB, indicating compressed the data by about 30X when saving the file.
Best I can tell from reading documentation and help forums, both V7 and V7.3 save files using compression. However, why would I be getting a file size expansion of 3X when using the V7.3 format?
댓글 수: 4
Osman Ciftci
2021년 11월 24일
Hi Peter, I have the same issue. It doesn't make much sense to me, and I also couldn't find good documentation to overcome this issue.
2 reasons I suspect are below, I need to analyze/experiment further before I can tell you I solved it:
1) Some data types are not very efficient when saving. Maybe using different date types could help. Instead of tables, using arrays might help.
2) .mat files might become corrupted, which could happen when saving the file to a network drive with bad connection.
Osman Ciftci
2021년 11월 24일
If you are having issues with -v7.3, you might want to try -v7. I did a quick test. For the same variables and workspace (tested both), -v7 .mat files are significantly smaller than -v7.3 .mat files.
답변 (1개)
Ankit Dutta
2019년 2월 19일
The size of the mat file is directly related to the size of the variables you are saving in it, plus some overhead for the structure. Since, in your case, you are saving a structure it adds on in the additional size of the file (when using -v7.3)
참고 항목
카테고리
Help Center 및 File Exchange에서 HDF5에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!