Matlab crashes when saving fig

In many cases, when saving the figure, the matlab crashes. It happens several times a day. It wasn't the case before 2015 version. It's very frustrating!!!!
Can anyone help?

8 个评论

Please post one of the crash logs.
I have been having the same problem in 2015b on OSX El Cap and,unfortunately, no crash log is ever generated. Crash logs are typically written to my Home directory but in this case MATLAB hangs in a busy state causing me to force-quit. The size of this particular contourf-created image, 100x8000, has not been an issue in other cases, my Java heap is set to 2012 MB and no error msg is ever generated. Thinking I need to do further testing.
I should also add I have verified each value in the matrix, from which contourf creates the figure, is finite, at least 1e3 times greater than realmin and contains no NaNs.
Russ, would it be possible for you to post code and data to test with? I could run it through my El Capitan system.
Hi Walter, Thank you for your interest. Here is my short code section. However, my guess is that it will not reveal the nature of the problem. I have 32 GB of RAM, my Java heap is now set at 4096 MB, and my code below has scaled the original 500x8000 matrix to 500x800. The pause at the end of the loop was only added thinking I was expecting too much too fast. I was wrong.
I've attached two files, the first being the only fig file saved after a long time, but not longer than five minutes. The second file attached is an image of the second figure displayed while MATLAB says it is busy, trying to save.
All that to say, I'll bet the nature of the problem is related to the data more than my simple code steps shown below.
numNans = sum( sum( isnan(VmdiffMag4) ))
for i = 1:10
figure('Position',[100 scrsz(4)/10 scrsz(3)/2 scrsz(4)/(8/7)]);
contourf(VmdiffMag4(:,1+(i-1)*800:800+(i-1)*800)); colorbar('FontSize',12);
figStr = sprintf('./fpiConv Figs/fpi2dDiff54_%2d.fig',i);
savefig(figStr);
pause
end
Oh goodness, MATLAB just startled me by finishing the second save in the loop above, and then displaying the next image. That must have taken 15-20 minutes and now it is ensconced in trying to save the next image. So apparently, this is a time issue and not a crash problem. Nevertheless, there still must be a problem. My machine has a 6 core processor, lots of muscle and is usually fast with everything ... just not when saving to a fig file.
I am seeing higher save times than I would naively expect. I used
foo = rand(500,1000);
[X,Y] = ndgrid(1:500,1:1000);
bar = foo .* X .* sin(2*pi*Y/200);
contourf(bar)
tic; savefig('/tmp/testfig.fig'); toc;
it hasn't finished yet; I will update this when I get a timing.
It was 4762 seconds, about 1 1/3 hours :(
Thank you for the corroboration.
I read, from another similar case, that certain graphics hardware required some kind of driver initialization. If this is true I'm not sure how to confirm and remediate.

请先登录,再进行评论。

回答(3 个)

The cure for R2014b and later, for the case where you do not need the file to be openable with MATLAB R2014a or earlier, is
tic; savefig(gcf, '/tmp/testfig.fig', 'compact'); toc;
This will save in a fraction of a second.

2 个评论

Great. I'll give this a try and report back.
Fantastic. That worked as promised. Thank you Walter!

请先登录,再进行评论。

John
John 2016-11-14
编辑:John 2016-11-15
That's not the issue.
When exam a figure (just plot or opened) and decide to save, then click on file->save or save as, the entire matlab crushes, very often. Many cases, the long time calculation just get lost along with the crush.

3 个评论

Please post a crash log. Also, which operating system and which MATLAB version are you using?
Where is the crush log? Windows 7 ultimate 64-bit. Problem occurs since 2014b or 2015a, it's now 2016a. Before it never had this problem. This is my 15th year of Matlab.
What kind of object are you requesting to save as? .fig? jpg? Or do you not get far enough to be given a choice?
I just tested in R2016a on a Windows 8 system and had no problem saving to fig or jpg.
Unfortunately I do not have a Windows 7 license available so I cannot test in Windows 7.

请先登录,再进行评论。

I ran into this thread and thought it was worth an update: I was struggling to understand why a figure I could see was not a figure I could save. I also was unable to file->saveas-> png, but I was able to save as a .fig. The issue was in the difference between PaperPosition and Position figure properties:
hf = figure;
paperSize=[50,50,1260,820];
printSize=[0 0 16 9];
hf.Position = paperSize;
hf.PaperPosition = printSize;
plot(1,1)
saveas(gcf, 'demo.fig')
saveas(gcf, 'demo.png')
hf = figure;
hf.PaperPosition = paperSize; %this is wrong
plot(1,1)
saveas(gcf, 'demo2.fig');
saveas(gcf, 'demo2.png'); %this line fails
If I accidentally put paperSize into PaperPosition, the function crashes. I imagine this is what a lot of the people on the thread are actually dealing with, but a large amount of data may also cause a crash.

1 个评论

I have the problem of seeing blue screen on saving the plot as jpg. So I tried the saveas code in the program. Now the plot got saved. Thank you Chad

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Startup and Shutdown 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by