Error saving matlab figure
63 次查看(过去 30 天)
显示 更早的评论
Hi, I am trying to save an imagesc figure and I am receiving this error. I have the 2022a MATLAB version. If anyone has any comment on how I could go about saving the figure that would be great. Thanks !
Warning: Variable 'hgS_070000' was not saved. For variables larger than 2GB use MAT-file version 7.3 or later.
> In matlab.graphics.internal.figfile.FigFile/write (line 32)
In savefig (line 83)
In saveasfig (line 6)
In saveas (line 153)
In filemenufcn>localSaveExportHelper (line 218)
In filemenufcn>localSaveExport (line 346)
In filemenufcn (line 58)
回答(1 个)
Aman Banthia
2023-9-28
Hi Natalia,
The error you're encountering typically occurs when trying to save a figure that exceeds the 2GB size limit of the standard “.fig” format.
One possible solution is to reduce the size of your figure. If your figure contains a large amount of data (e.g., a high-resolution image or a plot with many data points), try reducing the amount of data. For example, you could downsample the image or plot a subset of the data.
Alternatively, you could save the figure in a different format, such as “.png” or “.jpg ”, which may not have the same size limitations. This can be done using the ‘saveas’ function:
saveas(gcf,'filename.png')
Another solution, which is particularly useful if your figure is large due to extensive data, is to change the default MAT-file version to 7.3 in your MATLAB preferences. This version uses the HDF5-based format, which can handle larger files (more than 2GB).
To do this, go to Preferences -> General -> MAT-Files in your MATLAB environment and select "MATLAB Version 7.3 or later". Then use the ‘savefig’(function to save your figure.
savefig(gcf, 'filename.fig')
Please note that this change will allow ‘savefig’ to save the figure data in the -v7.3 format instead of the -v7 format. However, the -v7.3 MAT-files are not compatible with MATLAB versions prior to 7.7 (R2008b). If you need to open the saved figure in an earlier version of MATLAB, this solution will not work.
You can refer to the following MATLAB Answers link to view a similar question:
Hope that the above solution works.
Best Regards,
Aman Banthia
1 个评论
Zhaoru Liu
2024-2-28
Succesfully saved the .fig file by changing default MAT-file version to 7.3. Thanks a lot!
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Printing and Saving 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!