error using savefig and saveas

50 次查看(过去 30 天)
Hi guys! I get this error message but I don't understand why. I saw other people asked about it but I have no clue why it happens. Maybe because my fig is too big? I tried also with saveas(gcf, 'mosaico.fig') but it doesn't work.Thanks
Error using save
Error closing file C:\Users\utente\Desktop\TESI\CODICI\missione
GRID\gestire_sovrapposizioni\automatizzare\mosaico.fig.
The file may be corrupt.
Error in matlab.graphics.internal.figfile.FigFile/write (line 32)
save(obj.Path, obj.MatVersion, '-struct', 'SaveVars');
Error in savefig (line 83)
FF.write();
Error in f_massimi (line 53)
savefig('mosaico.fig')

采纳的回答

Dave B
Dave B 2021-10-30
I'm not sure why you're seeing this error, if it's due to the file being too large there are a couple of things that you can try:
1. Try appending the 'compact' flag to savefig:
This will prevent MATLAB from storing a compatibility layer which adds support for loading your figure in releases older than R2014b. The compatibility layer is quite large, so this makes a dramatic difference to file size, and also would work around any issues that are specific to this set of data.
savefig('mosaico.fig','compact')
2. Change your default mat file format, which can be done in the preferences window (under general). Setting this to version 7.3 or later will allow larger files.
However, the error reports a problem closing the file, which seems surprising for a large file. Perhaps something on the OS is using the file and MATLAB can't get write access? These sometimes show up for network drives, but it looks like you're targeting your desktop folder so I'd be surprised if there's an issue. But it still seems worth trying another a location?
  4 个评论
Dave B
Dave B 2021-11-1
Absolutely, unless you're planning on loading the fig files in a really old release I recommend it.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Printing and Saving 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by