error using savefig and saveas

83 visualizzazioni (ultimi 30 giorni)
Valeria Leto
Valeria Leto il 30 Ott 2021
Commentato: Valeria Leto il 1 Nov 2021
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')

Risposta accettata

Dave B
Dave B il 30 Ott 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 Commenti
Dave B
Dave B il 1 Nov 2021
Absolutely, unless you're planning on loading the fig files in a really old release I recommend it.
Valeria Leto
Valeria Leto il 1 Nov 2021
Thanks again!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Printing and Saving in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by