MATLAB function saves the current plot in pdf

Description

function [ ] = PrintPDF ( printonoff , pdfFilename , varargin )
% This function saves the current plot in pdf

p = inputParser ;
addParameter (p , ‘ papersize ‘ , [ 1 1 8 . 5 ] ) ;
addParameter (p , ‘ PageMargins ‘ , [ – 0 . 5 -0 . 5 0 0 ] ) ;
addParameter (p , ‘ Resolution ‘ , ‘ 600 ‘ ) ;

parse (p , varargin{ : } ) ;

pdfPaperSize = p.Results.papersize ;
PageMargins = p.Results.PageMargins ;
Res = p.Results.Resolution ;

if printonoff(1)==1 || strncmp ( printonoff , ‘Y ‘ , 1 ) || strcmpi ( printonoff , ‘ON’ )
fillPage( gcf , ‘margins ‘ , PageMargins , ‘ papersize ‘ , pdfPaperSize ) ; % [ left right top bottom]
print ( ‘-painters’ , ‘-dpdf ‘ , strcat ( ‘- r ‘ , Res ) , pdfFilename ) ;
h = msgbox ( sprintf ( ‘File saved in %s ‘ , pdfFilename ) , ‘ Success ‘ ) ;
end

https://www.datamentor.io/r-programming/saving-plot/

Reviews

There are no reviews yet.

Be the first to review “MATLAB function saves the current plot in pdf”
Category: