This is a static copy of a profile reportHome
print (40 calls, 34.812 sec)
Generated 05-Aug-2011 13:01:20 using cpu time.
function in file /usr/local/MATLAB/R2011a/toolbox/matlab/graphics/print.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
228 | LocalPrint(pj); | 40 | 34.025 s | 97.7% |  |
163 | [pj, devices, options ] = inpu... | 40 | 0.240 s | 0.7% |  |
160 | [pj, inputargs] = LocalCreateP... | 40 | 0.175 s | 0.5% |  |
197 | pj = name( pj ); | 40 | 0.087 s | 0.3% |  |
192 | pj = validate( pj ); | 40 | 0.087 s | 0.3% |  |
All other lines | | | 0.197 s | 0.6% |  |
Totals | | | 34.812 s | 100% | |
Children (called functions)
Code Analyzer results
No Code Analyzer messages.Coverage results
[ Show coverage for parent directory ]
Total lines in function | 230 |
Non-code lines (comments, blank lines) | 188 |
Code lines (lines that can run) | 42 |
Code lines that did run | 17 |
Code lines that did not run | 25 |
Coverage (did run/can run) | 40.48 % |
Function listing
time calls line
1 function varargout = print( varargin )
2 %PRINT Print figure or model. Save to disk as image or MATLAB file.
3 % SYNTAX:
4 % print
5 % PRINT alone sends the current figure to your current printer.
6 % The size and position of the printed output depends on the figure's
7 % PaperPosition[mode] properties and your default print command
8 % as specified in your PRINTOPT.M file.
9 %
10 % print -s
11 % Same as above but prints the current Simulink model.
12 %
13 % print -device -options
14 % You can optionally specify a print device (i.e., an output format such
15 % as tiff or PostScript or a print driver that controls what is sent to
16 % your printer) and options that control various characteristics of the
17 % printed file (i.e., the resolution, the figure to print
18 % etc.). Available devices and options are described below.
19 %
20 % print -device -options filename
21 % If you specify a filename, MATLAB directs output to a file instead of
22 % a printer. PRINT adds the appropriate file extension if you do not
23 % specify one.
24 %
25 % print( ... )
26 % Same as above but this calls PRINT as a MATLAB function instead of
27 % a MATLAB command. The difference is only in the parenthesized argument
28 % list. It allows the passing of variables for any of the input
29 % arguments and is especially useful for passing the handles
30 % of figures and/or models to print and filenames.
31 %
32 % Note: PRINT will produce a warning when printing a figure with a
33 % ResizeFcn. To avoid the warning, set the PaperPositionMode to 'auto'
34 % or match figure screen size in the PageSetup dialog.
35 %
36 % BATCH PROCESSING:
37 % You can use the function form of PRINT, which is useful for batch
38 % printing. For example, you can use a for loop to create different
39 % graphs and print a series of files whose names are stored in an array:
40 %
41 % for i=1:length(fnames)
42 % print('-dpsc','-r200',fnames(i))
43 % end
44 %
45 % SPECIFYING THE WINDOW TO PRINT
46 % -f<handle> % Handle Graphics handle of figure to print
47 % -s<name> % Name of an open Simulink model to print
48 % h % Figure or model handle when using function form of PRINT
49 %
50 % Examples:
51 % print -f2 % Both commands print Figure 2 using the default driver
52 % print( 2 ) % and operating system command specified in PRINTOPT.
53 %
54 % print -svdp % prints the open Simulink model named vdp
55 %
56 % SPECIFYING THE OUTPUT FILE:
57 % <filename> % String on the command line
58 % '<filename>' % String passed in when using function form of PRINT
59 %
60 % Examples:
61 % print -dps foo
62 % fn = 'foo'; print( gcf, '-dps', fn )
63 % Both save the current figure to a file named 'foo.ps' in the current
64 % working directory. This file can now be printed to a
65 % PostScript-compatible printer.
66 %
67 % COMMON DEVICE DRIVERS
68 % Output format is specified by the device driver input argument. This
69 % argument always starts with '-d' and falls into one of several
70 % categories:
71 % Microsoft Windows system device driver options:
72 % -dwin % Send figure to current printer in monochrome
73 % -dwinc % Send figure to current printer in color
74 % -dmeta % Send figure to clipboard (or file) in Metafile format
75 % -dbitmap % Send figure to clipboard (or file) in bitmap format
76 % -dsetup % Bring up Print Setup dialog box, but do not print
77 % -v % Verbose mode, bring up the Print dialog box
78 % which is normally suppressed.
79 %
80 % Built-in MATLAB Drivers:
81 % -dps % PostScript for black and white printers
82 % -dpsc % PostScript for color printers
83 % -dps2 % Level 2 PostScript for black and white printers
84 % -dpsc2 % Level 2 PostScript for color printers
85 %
86 % -deps % Encapsulated PostScript
87 % -depsc % Encapsulated Color PostScript
88 % -deps2 % Encapsulated Level 2 PostScript
89 % -depsc2 % Encapsulated Level 2 Color PostScript
90 %
91 % -dhpgl % HPGL compatible with Hewlett-Packard 7475A plotter
92 % -dill % Adobe Illustrator 88 compatible illustration file
93 % -djpeg<nn> % JPEG image, quality level of nn (figures only)
94 % E.g., -djpeg90 gives a quality level of 90.
95 % Quality level defaults to 75 if nn is omitted.
96 % -dtiff % TIFF with packbits (lossless run-length encoding)
97 % compression (figures only)
98 % -dtiffnocompression % TIFF without compression (figures only)
99 % -dpng % Portable Network Graphic 24-bit truecolor image
100 % (figures only)
101 %
102 % Other output formats are possible by using the GhostScript application
103 % supplied with MATLAB. For a full listing see the online help
104 % for GHOSTSCRIPT, use the command 'help private/ghostscript'.
105 % An example of some of the device drivers supported via GhostScript are:
106 % -dljet2p % HP LaserJet IIP
107 % -dljet3 % HP LaserJet III
108 % -ddeskjet % HP DeskJet and DeskJet Plus
109 % -dcdj550 % HP Deskjet 550C (UNIX only)
110 % -dpaintjet % HP PaintJet color printer
111 % -dpcx24b % 24-bit color PCX file format, 3 8-bit planes
112 % -dppm % Portable Pixmap (plain format)
113 %
114 % Examples:
115 % print -dwinc % Prints current Figure to current printer in color
116 % print( h, '-djpeg', 'foo') % Prints Figure/model h to foo.jpg
117 %
118 % PRINTING OPTIONS
119 % Options only for use with PostScript and GhostScript drivers:
120 % -loose % Use Figure's PaperPosition as PostScript BoundingBox
121 % -append % Append, not overwrite, the graph to PostScript file
122 % -tiff % Add TIFF preview, EPS files only (implies -loose)
123 % -cmyk % Use CMYK colors instead of RGB
124 % -adobecset % Use Adobe PostScript standard character set encoding
125 %
126 % Options for PostScript, GhostScript, Tiff, Jpeg, and Metafile:
127 % -r<number> % Dots-per-inch resolution. Defaults to 90 for Simulink,
128 % 150 for figures in image formats and when
129 % printing in Z-buffer or OpenGL mode, screen
130 % resolution for Metafiles and 864 otherwise.
131 % Use -r0 to specify screen resolution.
132 % Example:
133 % print -depsc -tiff -r300 matilda
134 % Saves current figure at 300 dpi in color EPS to matilda.eps
135 % with a TIFF preview (at 72 dpi for Simulink models and 150 dpi
136 % for figures). This TIFF preview will show up on screen if
137 % matilda.eps is inserted as a Picture in a Word document, but
138 % the EPS will be used if the Word document is printed on a
139 % PostScript printer.
140 %
141 % Other options for figure windows:
142 % -Pprinter % Specify the printer. On Windows and Unix.
143 % -noui % Do not print UI control objects
144 % -painters % Rendering for printing to be done in Painters mode
145 % -zbuffer % Rendering for printing to be done in Z-buffer mode
146 % -opengl % Rendering for printing to be done in OpenGL mode
147 % A note on renderers: when printing figures, MATLAB does not always
148 % use the same renderer as on screen. This is for efficiency reasons.
149 % There are cases, however, where the printed output is not exactly
150 % like the screen representation because of this. In these instances
151 % specifying -zbuffer or -opengl will more likely give you output that
152 % emulates the screen.
153 %
154 % See the Using MATLAB Graphics manual for more information on printing.
155 %
156 % See also PRINTOPT, PRINTDLG, ORIENT, IMWRITE, HGSAVE, SAVEAS.
157
158 % Copyright 1984-2010 The MathWorks, Inc.
159
0.17 40 160 [pj, inputargs] = LocalCreatePrintJob(varargin{:});
161
162 %Check the input arguments and flesh out settings of PrintJob
0.24 40 163 [pj, devices, options ] = inputcheck( pj, inputargs{:} );
164
0.01 40 165 if LocalHandleSimulink(pj)
166 return
167 end
168
169 %User can find out what devices and options are supported by
170 %asking for output and giving just the input argument '-d'.
171 %Do it here rather then inputcheck so stack trace makes more sense.
0.01 40 172 if strcmp( pj.Driver, '-d' )
173 if nargout == 0
174 disp('Supported devices are:')
175 for i=1:length(devices)
176 disp([' -d' devices{i}])
177 end
178 else
179 varargout{1} = devices;
180 varargout{2} = options;
181 end
182 %Don't actually print anything if user is inquiring.
183 return
184 end
185
186 %Be sure to restore pointers on exit.
0.04 40 187 pj = preparepointers( pj );
0.02 40 188 cleanupHandler = onCleanup(@() restorepointers(pj));
189
190 %Validate that PrintJob state is ok, that input arguments
191 %and defaults work together.
0.09 40 192 pj = validate( pj );
193
194 %Handle missing or illegal filename.
195 %Save possible name first for potential use in later warning.
40 196 tmpName = pj.FileName;
0.09 40 197 pj = name( pj );
198
199 %Check to see if filename is variable name in caller's workspace and
200 %warn if so -- continue in any case, if the filename specified did NOT
201 %have an extension (and could therefore possibly have meant a variable.
0.01 40 202 [~, fnname, fnext] = fileparts(tmpName);
40 203 if isempty(fnext) %if no extension, the name could have been a variable
204 LocalWarnAboutVarname(evalin('caller','who'),fnname);
205 end
206
207 %If only want to setup the output, do it and early exit.
208 %Currently this is a PC only thing, opens standard Windows Print dialog.
0.02 40 209 if setup( pj )
210 return
211 end
212
213 %Sometimes need help tracking down problems...
40 214 if pj.DebugMode
215 disp('Debugging in PRINT, PrintJob object is:')
216 disp(pj)
217 end
218
219 %If handled via new path just return from here, otherwise fall through
0.04 40 220 pj = alternatePrintPath(pj);
40 221 if pj.donePrinting
222 if pj.RGBImage
223 varargout(1) = {pj.Return};
224 end
225 return;
226 end
227
34.03 40 228 LocalPrint(pj);
229
40 230 end
Other subfunctions in this file are not included in this listing.