Error saving matlab figure

63 ビュー (過去 30 日間)
Natalia Matuk
Natalia Matuk 2022 年 3 月 21 日
コメント済み: Zhaoru Liu 2024 年 2 月 28 日
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)
  3 件のコメント
Natalia Matuk
Natalia Matuk 2022 年 3 月 21 日
Yes I did
Ive J
Ive J 2022 年 3 月 21 日

サインインしてコメントする。

回答 (1 件)

Aman Banthia
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
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 ExchangePrinting and Saving についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by