This is a static copy of a profile report

Home

legend>process_inputs (2 calls, 0.010 sec)
Generated 18-Mar-2011 23:31:46 using cpu time.
M-subfunction in file /Applications/MATLAB_R2010a.app/toolbox/matlab/scribe/legend.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
legend>make_legendM-subfunction2
Lines where the most time was spent

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

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