Figure plot only to file

조회 수: 4 (최근 30일)
nilsotto
nilsotto 2016년 2월 27일
댓글: nilsotto 2016년 2월 28일
Hi,
I have this code to plot a number of figures, but how do I change it to just write them to files without showing them on screen?
h=figure;
semilogx(Nacc(:,i),Range(:,i),'Color','blue','LineWidth',1.5);
xlabel('counts'); ylabel('Range'); grid on;
title(sprintf('max N=%.0f',Ntot(1,i)));
hold on;
semilogx(Nacc(:,i),EQLevel(:,i),'Color','red','LineWidth',1.5);
print(h,'-dpng',fname{1,i});
hold off;

답변 (1개)

Geoff Hayes
Geoff Hayes 2016년 2월 27일
nilsotto - to be clear, you just want to save the figure to file but not actually show the figure? Try setting its Visible property to off as in the following example.
x = -2*pi:0.01:2*pi;
y = sin(x);
h = figure('Visible','off');
plot(x,y);
print(h,'-dpng','mySineWave.png');
close(h);
The above code has been tested in R2014a.
  댓글 수: 1
nilsotto
nilsotto 2016년 2월 28일
Many thanks Geoff!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by