This is a static copy of a profile report

Home

strjust (120 calls, 0.006 sec)
Generated 04-Aug-2014 13:05:19 using cpu time.
function in file /share/apps/matlabr2014a/toolbox/matlab/strfun/strjust.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
num2str>strvrcatsubfunction120
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
38
return;
1200 s0%
37
t = s;
1200 s0%
36
if ~any(isspace(s(:,spaceCol))...
1200 s0%
35
if spaceCol
1200 s0%
30
spaceCol = n;
1200 s0%
All other lines  0.006 s100.0%
Totals  0.006 s100% 
Children (called functions)
No children
Code Analyzer results
Line numberMessage
49The value assigned here to 'dum' appears to be unused. Consider replacing it by ~.
52The value assigned here to 'dum' appears to be unused. Consider replacing it by ~.
55The value assigned here to 'dum' appears to be unused. Consider replacing it by ~.
56The value assigned here to 'dum' appears to be unused. Consider replacing it by ~.
Coverage results
Show coverage for parent directory
Total lines in function65
Non-code lines (comments, blank lines)23
Code lines (lines that can run)42
Code lines that did run12
Code lines that did not run30
Coverage (did run/can run)28.57 %
Function listing
time 
calls 
 line
   1 
function t = strjust(s,justify)
   2 
%STRJUST Justify character array.
   3 
%   T = STRJUST(S) or T = STRJUST(S,'right') returns a right justified 
   4 
%   version of the character array S.
   5 
%
   6 
%   T = STRJUST(S,'left') returns a left justified version of S.
   7 
%
   8 
%   T = STRJUST(S,'center') returns a center justified version of S.
   9 
%
  10 
%   See also DEBLANK, STRTRIM.
  11 

  12 
%   Copyright 1984-2006 The MathWorks, Inc.
  13 

    120 
  14 
if nargin<2 
    120 
  15 
    justify = 'right';  
  16 
else
  17 
    justify = lower(justify);
  18 
end
  19 

    120 
  20 
if isempty(s) 
  21 
    t = s; 
  22 
    return;
  23 
end
  24 

    120 
  25 
[m,n] = size(s); 
  26 

    120 
  27 
spaceCol = 0; 
    120 
  28 
switch justify 
    120 
  29 
case 'right' 
    120 
  30 
    spaceCol = n; 
  31 
case 'left'
  32 
    spaceCol = 1;
  33 
end
  34 

    120 
  35 
if spaceCol 
    120 
  36 
    if ~any(isspace(s(:,spaceCol))) 
    120 
  37 
        t = s; 
    120 
  38 
        return; 
  39 
    end        
  40 
end
  41 

  42 
% Find non-pad characters
  43 
ch = (s ~= ' ' & s ~= 0);
  44 
[r,c] = find(ch);
  45 

  46 
% Determine offset
  47 
switch justify
  48 
case 'right'
  49 
    [dum,offset] = max(fliplr(ch),[],2);
  50 
    offset =  offset - 1;
  51 
case 'left'
  52 
    [dum,offset] = max(ch,[],2);
  53 
    offset = 1 - offset;
  54 
case 'center'
  55 
    [dum,offsetR] = max(fliplr(ch),[],2);
  56 
    [dum,offsetL] = max(ch,[],2);
  57 
    offset = floor((offsetR - offsetL)/2);
  58 
otherwise
  59 
    error(message('MATLAB:strjust:UnknownParameter'));
  60 
end
  61 

  62 
% Apply offset to justify character array
  63 
newc = c + offset(r);
  64 
t = repmat(' ',m,n);
  65 
t(r + (newc-1)*m) = s(r + (c-1)*m);