Unable to save variables and figures of large arrays
8 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Stephen23
2018 年 11 月 14 日
編集済み: Stephen23
2018 年 11 月 14 日
"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 件のコメント
Marc Compere
2020 年 4 月 1 日
編集済み: Marc Compere
2020 年 4 月 1 日
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
2020 年 4 月 1 日
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:
その他の回答 (1 件)
Philipp Lauff
2024 年 6 月 30 日
Hi, I still encounter this problems (5 yeras later...) and I just took a look into the code. To fix it, follow these steps.
Copy from
"C:\Program Files\MATLAB\R2023b\toolbox\matlab\graphics\objectsystem\"
the file savefig.m and folder \private\ to your current working directory.
In the copied savefig.m add "FF.MatVersion = '-v7.3';" before the "FF.write();" (currently line 83). Now Matlab prefers your version of the savefig function and will use your code with the MAT-File version 7.3.
This is not the prettiest workaround as you have to copy the adjusted file and the folder to all your working directories (if you have mutliple), but changing it in the Matlab folder won't do the trick. I suppose, these files are precompiled and therefore changes are not executed.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Printing and Saving についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!