MATLAB Answers

Unable to save variables and figures of large arrays

58 views (last 30 days)
Kobi
Kobi on 13 Nov 2018
Commented: Marc Compere on 1 Apr 2020
i keep getting this error:
Warning: Variable 'hgS_070000' cannot be saved to a MAT-file whose version is older than 7.3.
To save this variable, use the -v7.3 switch.
Skipping...
> In matlab.graphics.internal.figfile.FigFile/write (line 32)
In savefig (line 84)
Error using save
Error closing file D:\Dropbox (Personal)\C\Resaults\2018_11_13_21_45_10.926(Temperature map).fig.
Error in matlab.graphics.internal.figfile.FigFile/write (line 32)
save(obj.Path, obj.MatVersion, '-struct', 'SaveVars');
Error in savefig (line 84)
FF.write();
i use this command
savefig([time_stamp,'(LASER)','.fig'])
saveas(gcf,[time_stamp,'(LASER)','.png'])
the arrays are really big 15000x30000
what is the meaning of this error?
how to avoid it?

  0 Comments

Sign in to comment.

Accepted Answer

Stephen Cobeldick
Stephen Cobeldick on 14 Nov 2018
Edited: Stephen Cobeldick on 14 Nov 2018
"what is the meaning of this error?"
The .fig file format is really just a .mat that stores all of the objects in a figure. Most of the time this happens quite seamlessly, so the user never notices or cares how .fig files are saved. But .mat files are not all the same: in particular, the size of arrays that can be saved has increased significantly as MATLAB has developed. You can see these differences summarized here:
What appears to have happened is that whoever wrote the .fig saving code did not consider that someone might want to save a figure with such a huge amount of data, and the size is beyond the specification for the default .mat file version that the .fig saving code uses (here in bytes):
>> 2^31
ans = 2147483648
>> 15000*30000*8
ans = 3600000000
"how to avoid it?"
You might like to try using saveas, to see if it handles this better.
Otherwise I doubt that there is a simple solution, but I think you should definitely report this as a bug.

  6 Comments

Show 3 older comments
Stephen Cobeldick
Stephen Cobeldick on 18 Nov 2018
Dropbox folders can cause problems. Try saving using a simple filename (e.g. "test.fig") to a normal user directory.
Marc Compere
Marc Compere on 1 Apr 2020
I have this same issue on Ubuntu 18 Linux in R2019a.
The savefig command it's still failing with a simple file: /tmp/tmp.fig:
>> saveStr = '/tmp/tmp.fig';
>> savefig(h,saveStr,'compact')
Error using save
Error closing file /tmp/tmp.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();
>>
This appears to be a bug. The other figures of similar complexity generate .fig files less than 0.5Mb. The figures have lots of data but the resulting .fig files are not large for those that work.
Matlab has a resident memory footprint of 12Gb on a machine with plenty of more ram than that. The problem is not lack of physical memory but still this file writing process fails.
The failuse occurrs with and without the 'compact' designator.
Writing to .png files works fine. It's the .fig file format that is the problem.
Any solutions????
Marc Compere
Marc Compere on 1 Apr 2020
This is the png export of a figure that fails when attempting to write the .fig file. It has subplots and a fair amount of data but it's not unreasonable:

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Products


Release

R2016a