This is a static copy of a profile reportHome
legend>process_inputs (14 calls, 0.033 sec)
Generated 05-Aug-2011 13:00:27 using cpu time.
subfunction in file /usr/local/MATLAB/R2011a/toolbox/matlab/scribe/legend.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 |
489 | locationAbbrevs{k} = str(str&g... | 266 | 0.011 s | 33.3% |  |
488 | str = locations{k}; | 266 | 0.011 s | 33.3% |  |
579 | strings = strings(:).'; | 14 | 0 s | 0% |  |
578 | end | 34 | 0 s | 0% |  |
577 | n = n + 1; | 34 | 0 s | 0% |  |
All other lines | | | 0.011 s | 33.3% |  |
Totals | | | 0.033 s | 100% | |
Children (called functions)
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
iscellstr | function | 9 | 0 s | 0% |  |
Self time (built-ins, overhead, etc.) | | | 0.033 s | 100.0% |  |
Totals | | | 0.033 s | 100% | |
Code Analyzer results
Line number | Message |
536 | { A{:} B } can often be replaced by [ A {B}], which can be much faster. |
540 | The variable 'strings' appears to change size on every loop iteration. Consider preallocating for speed. |
Coverage results
[ Show coverage for parent directory ]
Total lines in function | 125 |
Non-code lines (comments, blank lines) | 39 |
Code lines (lines that can run) | 86 |
Code lines that did run | 42 |
Code lines that did not run | 44 |
Coverage (did run/can run) | 48.84 % |
Function listing
time calls line
455 function [orient,location,position,children,listen,strings,propargs] = process_inputs(ax,argin)
456
14 457 orient='vertical'; location='';
14 458 position=[];
14 459 children = []; strings = {}; propargs = {};
14 460 listen = false;
461
14 462 nargs = length(argin);
14 463 if nargs==0
464 return;
465 end
466
14 467 if ischar(argin{1}) && strcmpi(argin{1},'-DynamicLegend')
468 listen = true;
469 argin(1) = [];
470 nargs = nargs-1;
471 if nargs==0
472 return;
473 end
474 end
475
476 % Get location strings long and short form. The short form is the
477 % long form without any of the lower case characters.
14 478 locations = findtype('LegendLocationPreset');
14 479 if isempty(locations)
480 % explicitly load UDD class and get again
481 pkg = findpackage('scribe');
482 findclass(pkg,'legend');
483 locations = findtype('LegendLocationPreset');
484 end
14 485 locations = locations.Strings;
14 486 locationAbbrevs = cell(length(locations),1);
14 487 for k=1:length(locations)
0.01 266 488 str = locations{k};
0.01 266 489 locationAbbrevs{k} = str(str>='A' & str<='Z');
266 490 end
491
492 % Loop over inputs and determine strings, handles and options
14 493 n = 1;
14 494 foundAllStrings = false;
14 495 while n <= nargs
34 496 if ischar(argin{n})
24 497 if strcmpi(argin{n},'orientation')
498 if (n < nargs) && ...
499 ischar(argin{n+1}) && ...
500 ((strncmpi(argin{n+1},'hor',3)) || ...
501 (strncmpi(argin{n+1},'ver',3)))
502 % found 'Orientation',ORIENT
503 if strncmpi(argin{n+1},'hor',3)
504 orient = 'horizontal';
505 else
506 orient = 'vertical';
507 end
508 n = n + 1; % skip 'Orientation'
509 else
510 error(id('UnknownParameter'),...
511 'Invalid argument to orientation. Type ''help legend'' for more information.');
512 end
24 513 elseif strcmpi(argin{n},'location')
10 514 if (n < nargs) && ...
515 isnumeric(argin{n+1}) && (length(argin{n+1})==4)
516 % found 'Location',POS
517 position = argin{n+1};
518 location = 'none';
10 519 elseif (n < nargs) && ...
520 ischar(argin{n+1}) && ...
521 (any(strcmpi(argin{n+1}, locations)) || ...
522 any(strcmpi(argin{n+1}, locationAbbrevs)))
523 % found 'Location',LOC
10 524 location = argin{n+1};
525 % look up the long form location string if needed
10 526 abbrev = find(strcmpi(location, locationAbbrevs));
10 527 if ~isempty(abbrev)
528 location = locations{abbrev};
529 end
530 else
531 error(id('UnknownParameter'),...
532 'Invalid argument to location. Type ''help legend'' for more information.');
533 end
10 534 n = n + 1; % skip 'Location'
14 535 elseif foundAllStrings && (n < nargs)
536 propargs = {propargs{:}, argin{n:n+1}};
537 n = n + 1;
14 538 else
539 % found a string for legend entry
14 540 strings{end+1} = argin{n}; % single item string
14 541 end
10 542 elseif isnumeric(argin{n}) && length(argin{n})==1 && ...
543 mod(argin{n},1)==0
544 % a whole number so a numeric location
545 % the number might coincidentally be a figure handle, but a figure
546 % would never be an input
547 location = get_location_from_numeric(argin{n});
10 548 elseif isnumeric(argin{n}) && length(argin{n})==4 && ...
549 (n > 1 || ~all(ishandle(argin{n})))
550 % to use position vector either it must not be the first argument,
551 % or if it is, then the values must not all be handles - in which
552 % case the argument will be considered to be the plot children
553 % This is an undocumented API for backwards compatibility with
554 % Basic Fitting.
555 position = argin{n};
556 fig = ancestor(ax,'figure');
557 position = hgconvertunits(fig,position,'points','normalized', fig);
558 center = position(1:2)+position(3:4)/2;
559 % .001 is a small number so that legend will resize to fit and centered
560 position = [center-.001 0.001 0.001];
561 location = 'none';
10 562 elseif iscell(argin{n})
563 % found cell array of strings for legend entries
9 564 if ~iscellstr(argin{n})
565 error(id('InvalidCellParameter'),...
566 'Cell array argument must be a cell array of strings.');
567 end
9 568 strings = argin{n};
9 569 foundAllStrings = true;
1 570 elseif n==1 && all(ishandle(argin{n}))
571 % found handles to put in legend
1 572 children=argin{n}';
573 else
574 error(id('UnknownParameter'),...
575 'Invalid argument. Type ''help legend'' for more information.');
576 end
34 577 n = n + 1;
34 578 end
14 579 strings = strings(:).';
Other subfunctions in this file are not included in this listing.