strjust>strjustOnChar (Calls: 56, Time: 0.008 s)
Generated 16-Jul-2020 17:09:46 using performance time.
subfunction in file /Applications/MATLAB_R2020a.app/toolbox/matlab/strfun/strjust.m
Copy to new window for comparing multiple runs
Function Name | Function Type | Calls |
strjust | function | 56 |
Line Number | Code | Calls | Total Time | % Time | Time Plot |
69 | [dum,offset] = max(fliplr(ch),... | 56 | 0.002 s | 26.6% | |
85 | t(r + (newc-1)*m) = s(r + (c-1... | 56 | 0.001 s | 14.4% | |
83 | newc = c + offset(r); | 56 | 0.001 s | 9.6% | |
84 | t = repmat(' ',m,n); | 56 | 0.001 s | 7.5% | |
56 | if ~any(isspace(s(:,spaceCol))... | 56 | 0.001 s | 7.3% | |
All other lines | 0.003 s | 34.7% | |||
Totals | 0.008 s | 100% |
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
fliplr | function | 56 | 0.001 s | 9.7% | |
Self time (built-ins, overhead, etc.) | 0.008 s | 90.3% | |||
Totals | 0.008 s | 100% |
Line number | Message |
69 | The value assigned here to 'dum' appears to be unused. Consider replacing it by ~. |
72 | The value assigned here to 'dum' appears to be unused. Consider replacing it by ~. |
75 | The value assigned here to 'dum' appears to be unused. Consider replacing it by ~. |
76 | The value assigned here to 'dum' appears to be unused. Consider replacing it by ~. |
Total lines in function | 49 |
Non-code lines (comments, blank lines) | 11 |
Code lines (lines that can run) | 38 |
Code lines that did run | 23 |
Code lines that did not run | 15 |
Coverage (did run/can run) | 60.53 % |
time | Calls | line | |
---|---|---|---|
38 | function t = strjustOnChar(s,justify) | ||
39 | |||
< 0.001 | 56 | 40 | if isempty(s) |
41 | t = s; | ||
42 | return; | ||
< 0.001 | 56 | 43 | end |
44 | |||
< 0.001 | 56 | 45 | [m,n] = size(s); |
46 | |||
< 0.001 | 56 | 47 | spaceCol = 0; |
< 0.001 | 56 | 48 | switch justify |
< 0.001 | 56 | 49 | case 'right' |
< 0.001 | 56 | 50 | spaceCol = n; |
51 | case 'left' | ||
52 | spaceCol = 1; | ||
< 0.001 | 56 | 53 | end |
54 | |||
< 0.001 | 56 | 55 | if spaceCol |
< 0.001 | 56 | 56 | if ~any(isspace(s(:,spaceCol))) |
57 | t = char(s); | ||
58 | return; | ||
< 0.001 | 56 | 59 | end |
< 0.001 | 56 | 60 | end |
61 | |||
62 | % Find non-pad characters | ||
< 0.001 | 56 | 63 | ch = (s ~= ' ' & s ~= 0); |
< 0.001 | 56 | 64 | [r,c] = find(ch); |
65 | |||
66 | % Determine offset | ||
< 0.001 | 56 | 67 | switch justify |
< 0.001 | 56 | 68 | case 'right' |
0.002 | 56 | 69 | [dum,offset] = max(fliplr(ch),[],2); |
< 0.001 | 56 | 70 | offset = offset - 1; |
71 | case 'left' | ||
72 | [dum,offset] = max(ch,[],2); | ||
73 | offset = 1 - offset; | ||
74 | case 'center' | ||
75 | [dum,offsetR] = max(fliplr(ch),[],2); | ||
76 | [dum,offsetL] = max(ch,[],2); | ||
77 | offset = floor((offsetR - offsetL)/2); | ||
78 | otherwise | ||
79 | error(message('MATLAB:strjust:UnknownParameter')); | ||
< 0.001 | 56 | 80 | end |
81 | |||
82 | % Apply offset to justify character array | ||
< 0.001 | 56 | 83 | newc = c + offset(r); |
< 0.001 | 56 | 84 | t = repmat(' ',m,n); |
0.001 | 56 | 85 | t(r + (newc-1)*m) = s(r + (c-1)*m); |
< 0.001 | 56 | 86 | end |
Other subfunctions in this file are not included in this listing.