error using savefig and saveas

29 visualizaciones (últimos 30 días)
Valeria Leto
Valeria Leto el 30 de Oct. de 2021
Comentada: Valeria Leto el 1 de Nov. de 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')

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Printing and Saving en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by