Why does the "matfile" function create files larger in size compared to the "save" function?

Comparing "matfile" and "save" with "-v7.3" shows different file sizes if the variables are objects (e.g. tabular classes, or Simulink objects like "Simulink.Signal").
If you save certain variables (object, e.g., tabular classes, or Simulink objects like "Simulink.Signal") with "save" (option "-v7.3"), the resulting file size is much smaller compared to using the "matfile" function to update existing variables in the MAT file.

 채택된 답변

MathWorks Support Team
MathWorks Support Team 2026년 4월 21일 0:00
편집: MathWorks Support Team 2026년 4월 21일 9:02
This is a known limitation when updating existing variables in a MAT-File: the MAT-File's size can increase, especially if the variable is an object. Using the "matfile" object to update variables is equivalent to using "save" with the "-append" flag. Therefore, you see the size increase using the "matfile" object and using "save" with "-append". 
The only workaround is to re-save to a new MAT-File, using "save" or "matfile" object (to a new MAT-File). This would create a whole new file, and the size would be, as one would expect.
This is also documented in this Bug Report.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

제품

릴리스

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by