MATLAB Answers


Unable to save variables and figures of large arrays

Asked by Kobi
on 13 Nov 2018
Latest activity Commented on by Stephen Cobeldick on 18 Nov 2018
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.
> In (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 (line 32)
save(obj.Path, obj.MatVersion, '-struct', 'SaveVars');
Error in savefig (line 84)
i use this command
the arrays are really big 15000x30000
what is the meaning of this error?
how to avoid it?


Sign in to comment.




1 Answer

Answer by Stephen Cobeldick on 14 Nov 2018
Edited by Stephen Cobeldick on 14 Nov 2018
 Accepted Answer

"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.


Show 1 older comment
It seems that savefig can save figures using version 7.3 .mat files (which support >2GB variables), by using the 'compact' option:
savefig was introduced in R2013b.
Hi Stephen,
it didn't work
this is the error i get:
Error using save
Error closing file D:\Dropbox\C\Resaults\2018_11_18_11_51_40.627(LASER).fig.
Error in (line 32)
save(obj.Path, obj.MatVersion, '-struct', 'SaveVars');
Error in savefig (line 84)
Error in script_conv (line 111)
what can be done to fix it?
Dropbox folders can cause problems. Try saving using a simple filename (e.g. "test.fig") to a normal user directory.

Sign in to comment.