Matlab crashes when saving fig
Mostrar comentarios más antiguos
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 comentarios
Walter Roberson
el 8 de Jul. de 2016
Please post one of the crash logs.
Russ Park
el 23 de Oct. de 2016
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.
Russ Park
el 23 de Oct. de 2016
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.
Walter Roberson
el 23 de Oct. de 2016
Russ, would it be possible for you to post code and data to test with? I could run it through my El Capitan system.
Russ Park
el 23 de Oct. de 2016
Editada: Walter Roberson
el 23 de Oct. de 2016
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.

Walter Roberson
el 23 de Oct. de 2016
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.
Walter Roberson
el 24 de Oct. de 2016
It was 4762 seconds, about 1 1/3 hours :(
Russ Park
el 24 de Oct. de 2016
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.
Respuestas (3)
Walter Roberson
el 24 de Oct. de 2016
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.
3 comentarios
Walter Roberson
el 14 de Nov. de 2016
Please post a crash log. Also, which operating system and which MATLAB version are you using?
John
el 15 de Nov. de 2016
Walter Roberson
el 15 de Nov. de 2016
Editada: Walter Roberson
el 15 de Nov. de 2016
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.
Chad
el 28 de Sept. de 2017
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 comentario
Nicholas George
el 15 de Jun. de 2022
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
Categorías
Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!