This is a static copy of a profile report

Home

saveas (6 calls, 22.638 sec)
Generated 14-Nov-2016 07:47:06 using cpu time.
function in file /usr/local/MATLAB/MATLAB_Production_Server/R2015a/toolbox/matlab/general/saveas.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
LOH_hapmap_v4function4
allelic_ratios_WGseqfunction2
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
168
print( h, name, ['-d' dev{i}] ...
622.547 s99.6%
146
[ops,dev,ext] = printtables(pr...
60.050 s0.2%
128
if ~isempty(fp) && ~ex...
60.030 s0.1%
139
if ~isempty(format) &&...
60.010 s0.0%
169
return
60 s0%
All other lines  0 s0%
Totals  22.638 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
printfunction622.547 s99.6%
printtablesfunction60.040 s0.2%
printjobfunction60.010 s0.0%
cell.strmatchfunction90 s0%
filepartsfunction60 s0%
general/private/isfigurefunction60 s0%
Self time (built-ins, overhead, etc.)  0.040 s0.2%
Totals  22.638 s100% 
Code Analyzer results
Line numberMessage
154STRMATCH is not recommended. Use STRCMP instead.
Coverage results
Show coverage for parent directory
Total lines in function172
Non-code lines (comments, blank lines)100
Code lines (lines that can run)72
Code lines that did run28
Code lines that did not run44
Coverage (did run/can run)38.89 %
Function listing
time 
calls 
 line
   1 
function saveas( h, name, format )
   2 
%SAVEAS Save Figure or Simulink block diagram in desired output format
   3 
%   SAVEAS(H,'FILENAME')
   4 
%   Will save the Figure or Simulink block diagram with handle H to file 
   5 
%   called FILENAME. 
   6 
%   The format of the file is determined from the extension of FILENAME.
   7 
%
   8 
%   SAVEAS(H,'FILENAME','FORMAT')
   9 
%   Will save the Figure or Simulink block diagram  with handle H to file 
  10 
%   called FILENAME in the format specified by FORMAT. FORMAT can be the 
  11 
%   same values as extensions of FILENAME. 
  12 
%   The FILENAME extension does not have to be the same as FORMAT.  
  13 
%   The specified FORMAT overrides FILENAME extension.
  14 
%
  15 
%   Valid options for FORMAT are:
  16 
%
  17 
%   'fig'  - save figure to a single binary FIG-file.  Reload using OPEN. 
  18 
%   'm'    - save figure to binary FIG-file, and produce callable
  19 
%            MATLAB code file for reload.
  20 
%   'mfig' - same as M.
  21 
%   'mmat' - save figure to callable MATLAB code file as series of creation
  22 
%            commands with param-value pair arguments.  Large data is saved
  23 
%            to MAT-file.  
  24 
%            Note: MMAT Does not support some newer graphics features. Use
  25 
%                  this format only when code inspection is the primary goal.
  26 
%                  FIG-files support all features, and load more quickly. 
  27 
%
  28 
%   Additional FORMAT options include devices allowed by PRINT.
  29 
%
  30 
%   NOTE: not all format options are allowed for Simulink block diagrams.
  31 
%   See the online help for more information.
  32 
%
  33 
%   Examples:
  34 
%
  35 
%   Write current figure to MATLAB fig file
  36 
%
  37 
%       saveas(gcf, 'output', 'fig')
  38 
%
  39 
%   Write current figure to windows bitmap file
  40 
%
  41 
%       saveas(gcf, 'output', 'bmp')
  42 
%
  43 
%   Write block diagram named 'demo' to an Encapsulated Postscript file
  44 
%
  45 
%       saveas(get_param('demo', 'Handle'), 'output', 'eps')
  46 
%
  47 
%   In the following list, SAVE_SYSTEM is available for Simulink users only. 
  48 
%   See also LOAD, SAVE, OPEN, PRINT, SAVE_SYSTEM
  49 

  50 
%   Copyright 1984-2011 The MathWorks, Inc.
  51 

  52 
%Input validation
      6 
  53 
if nargin < 2  
  54 
    error(message('MATLAB:saveas:tooFewInputs'))
  55 
end
  56 

      6 
  57 
if ~all(ishandle(h)) 
  58 
    error('MATLAB:saveas:invalidHandle','%s',...
  59 
        getString(message('MATLAB:saveas:invalidHandle')))
  60 
end
  61 

      6 
  62 
if all(ishghandle(h)) 
  63 
    
      6 
  64 
    notfig = find(~isfigure(h));  
      6 
  65 
    if ~isempty(notfig) 
  66 
        for n = notfig
  67 
            hP = ancestor(h(n), 'figure');
  68 
            if isempty(hP)
  69 
                % At least one of the objects has no figure parent.  Don't save
  70 
                % any of them
  71 
                h = [];
  72 
                break;
  73 
            else
  74 
                % Update non-figure with the parent figure
  75 
                h(n) = hP;
  76 
            end
  77 
        end
  78 
    end
  79 
  
      6 
  80 
    if isempty(h) 
  81 
        error('MATLAB:saveas:invalidHandle','%s',...
  82 
           getString(message('MATLAB:saveas:invalidFigureHandle')))
  83 
    end
  84 
    
  85 
else
  86 
    if ~strcmp( 'block_diagram', get_param( h, 'type' ) ) ...
  87 
            && ~strcmp( 'SubSystem', get_param( h, 'blocktype' ) )
  88 
        error('MATLAB:saveas:invalidHandle','%s',...
  89 
            getString(message('MATLAB:saveas:invalidSimulinkHandle')))
  90 
    end
  91 
end
  92 

  93 

      6 
  94 
if ~ischar(name) || isempty(name) 
  95 
    error('MATLAB:saveas:invalidFilename','%s',...
  96 
    getString(message('MATLAB:saveas:invalidFilename')));
  97 
end
  98 

  99 
% since this is a callback from the figure menu, it is possible that
 100 
% uimenufcn will give a bogus filename (one with a * in it) if we get
 101 
% any *'s in the filename, error out gracefully.
 102 
% might want to generalize this to the same set of chars windows prevents
 103 
% in filenames - could be crippling on unix though.
      6 
 104 
if any(name == '*') 
 105 
    error('MATLAB:saveas:invalidFilename','%s',...
 106 
         getString(message('MATLAB:saveas:invalidFilenameAsterisk', name)))
 107 
end
 108 

 109 
% Make sure we can write given file. Note fileparts returns leaf directory in
 110 
% name return argument if given filename is only a path, i.e. 'c:\temp'.
      6 
 111 
[fp,fn,fe]=fileparts(name); 
 112 

 113 
% NOTE: this does not allow to say:
 114 
% saveas(gcf, 'foo.', '-fig')
 115 
% maybe that's OK...
 116 
% william - 11/98
      6 
 117 
if ~isempty(fe) && strcmp(fe, '.') 
 118 
    error('MATLAB:saveas:invalidFilename','%s',...
 119 
        getString(message('MATLAB:saveas:invalidFilenameExtension',name)));
 120 
end
      6 
 121 
if isempty(fe) 
 122 
   fe = '.fig';
 123 
end
      6 
 124 
if isempty(fn)  
 125 
    error('MATLAB:saveas:invalidFilename','%s',...
 126 
        getString(message('MATLAB:saveas:invalidFilenameFile',name)));
 127 
end
  0.03 
      6 
 128 
if ~isempty(fp) && ~exist(fp, 'dir') 
 129 
    error('MATLAB:saveas:invalidFilename','%s',...
 130 
        getString(message('MATLAB:saveas:invalidFilenameBadPath' ,name)))
 131 
end
 132 

      6 
 133 
if nargin == 2 
 134 
    format = fe(2:end); %Do not want the '.'
 135 
end
 136 

 137 
%For some formats we have helper SAVEAS... functions
 138 
% make sure format is defined to prevent recursion into this file
  0.01 
      6 
 139 
if ~isempty(format) && any( exist( ['saveas' format]) == [2 3 5 6] ) %#ok 
 140 
    feval( ['saveas' format], h, name )
 141 
    
      6 
 142 
else     
 143 
    %If FORMAT is specified, look first to see if it is an extension
 144 
    %we know is that of a PRINT output format. If not, look to see if
 145 
    %it is a PRINT supported device format specifier.
  0.05 
      6 
 146 
    [ops,dev,ext] = printtables(printjob(h)); %#ok 
      6 
 147 
    i = strmatch( format, ext ); %#ok 
 148 
    
      6 
 149 
    if length(i) >= 1 
 150 
        %Handle special cases, more then one device, i.e. format='ps'
      3 
 151 
        i = i(1); 
 152 
        
      3 
 153 
    elseif isempty(i) 
      3 
 154 
        i = strmatch( format, dev, 'exact'  ); 
      3 
 155 
        if isempty(i) 
 156 
            i = strmatch( format, dev  ); %#ok
 157 
            if ~isempty(i)
 158 
                %Need to handle cases of multiple devices, i.e. format='ljet'
 159 
                i = i(1);
 160 
            end
 161 
        end
      3 
 162 
    end 
 163 
    
 164 
    %FORMAT is a PRINT support ext or driver
      6 
 165 
    if isempty(i) 
 166 
        error(message('MATLAB:saveas:badFormat', format))
      6 
 167 
    else 
 22.55 
      6 
 168 
        print( h, name, ['-d' dev{i}] ) 
      6 
 169 
        return 
 170 
    end
 171 
    
 172 
end

Other subfunctions in this file are not included in this listing.