error using savefig and saveas
29 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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')
0 commentaires
Réponse acceptée
Dave B
le 30 Oct 2021
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 commentaires
Dave B
le 1 Nov 2021
Absolutely, unless you're planning on loading the fig files in a really old release I recommend it.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Printing and Saving dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!