save image with better resolution

2 Ansichten (letzte 30 Tage)
Jeffrey Schlang
Jeffrey Schlang am 29 Jun. 2017
Hello ... trying to save a plot with screen resolution or better
The saveas works but the resolution is not so good like the original plot The print gives me an error ...
Thanks in advance for any help
matlab code
if flag_ppt
bb=gca;
filedir11=strcat(PlotDir,'Plot1.png') ;
saveas(bb, filedir11,'png');
print(bb,filedir11, '-dpng','-r0')
end
Error messages:
Error using checkArgsForHandleToPrint
MATLAB Graphics handle must be a figure.
Error in checkArgsForHandleToPrint
Error in print>LocalCreatePrintJob (line 326)
handles = checkArgsForHandleToPrint(0, varargin{:});
Error in print (line 150)
[pj, inputargs] = LocalCreatePrintJob(varargin{:});
Error in Read_Noise_Src_ENR_fct_revB (line 234)
print(bb,filedir11, '-dpng','-r0')
Error in MAIN_EDM_Noise_gui (line 224)
Read_Noise_Src_ENR_fct_revB(flag_plot,scrsz, flag_ppt, ...
Error in AE_Gue_revA>CmpParam_Callback (line 398)
MAIN_EDM_Noise_gui
Error in gui_mainfcn (line 95)
feval(varargin{:});

Antworten (2)

Walter Roberson
Walter Roberson am 29 Jun. 2017
print() does not work on axes, only on figures. If you have an axes to output and the rest of the figure should not be output, then create a second figure, copyobj() the axes to it, print the temporary figure, and then delete it.
We suggest you look at the export_fig File Exchange contribution.

Michael Dombrowski
Michael Dombrowski am 29 Jun. 2017
Bearbeitet: Michael Dombrowski am 29 Jun. 2017
You have an error with your code which is that print() takes a figure handle, not axes handle. See the print documentation here.
If you want a higher resolution, try using -r800 for 800 DPI.
if flag_ppt
bb=gcf;
filedir11=strcat(PlotDir,'Plot1.png');
print(bb, filedir11, '-dpng','-r800')
end

Kategorien

Mehr zu Printing and Saving finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by