This is a static copy of a profile reportHome
opaque.char (206 calls, 0.050 sec)
Generated 05-Nov-2014 07:52:32 using cpu time.
function in file /usr1/opt/matlab/7.13/toolbox/matlab/datatypes/@opaque/char.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 |
22 | cel = cell(opaque_array); | 206 | 0.020 s | 40.0% |  |
31 | if isa(opaque_array,'java.lang... | 206 | 0.010 s | 20.0% |  |
33 | return; | 206 | 0 s | 0% |  |
32 | chr = cel{1}; | 206 | 0 s | 0% |  |
21 | try | 206 | 0 s | 0% |  |
All other lines | | | 0.020 s | 40.0% |  |
Totals | | | 0.050 s | 100% | |
Children (called functions)
No childrenCode Analyzer results
Line number | Message |
45 | Best practice is for CATCH to be followed by an identifier that gets the error information. |
63 | FINDSTR will be removed in a future release. Use STRFIND instead. |
Coverage results
[ Show coverage for parent directory ]
Total lines in function | 101 |
Non-code lines (comments, blank lines) | 43 |
Code lines (lines that can run) | 58 |
Code lines that did run | 6 |
Code lines that did not run | 52 |
Coverage (did run/can run) | 10.34 % |
Function listing
time calls line
1 function chr = char(opaque_array)
2 %CHAR Convert a Java object to CHAR
3
4 % Chip Nylander, June 1998
5 % Copyright 1984-2007 The MathWorks, Inc.
6 % $Revision: 1.12.4.4 $ $Date: 2007/12/06 13:29:41 $
7
8 %
9 % For opaque types other than those programmed here, just run the default
10 % builtin char function.
11 %
206 12 if ~isjava(opaque_array)
13 chr = builtin('char', opaque_array);
14 return;
15 end
16
17 %
18 % Convert opaque array to cell array to get the items in it.
19 %
20
206 21 try
0.02 206 22 cel = cell(opaque_array);
23 catch exception %#ok
24 chr = '';
25 return;
26 end
27
28 %
29 % A java.lang.String object becomes a char array.
30 %
0.01 206 31 if isa(opaque_array,'java.lang.String')
206 32 chr = cel{1};
206 33 return;
34 end
35
36 %
37 % An empty Java array becomes an empty char array.
38 %
39 sz = builtin('size', cel);
40 psz = prod(sz);
41
42 if psz == 0
43 try
44 chr = reshape('',size(cel));
45 catch
46 chr = '';
47 end
48 return;
49 end;
50
51 %
52 % A java.lang.String array becomes a char array.
53 %
54 chr = cell(sz);
55
56 for i=1:psz
57 chr{i} = '';
58 end
59
60 t = opaque_array(1);
61 c = class(t);
62
63 while ~isempty(findstr(c,'[]'))
64 t = t(1);
65 c = class(t);
66 end
67
68 if psz == 1 && ischar(t) && size(t,1) == 1
69 chr = t;
70 return;
71 end
72
73 if isa(t,'java.lang.String')
74 chr = char(cel);
75 return;
76 end
77
78 %
79 %
80 % Run toChar on each Java object in the MATLAB array. This will error
81 % out if a toChar method is not available for the Java class of the object.
82 %
83 % A scalar array becomes a single char array.
84 %
85 if psz == 1
86 if ~isjava(opaque_array(1))
87 chr = builtin('char',opaque_array(1));
88 else
89 chr = toChar(opaque_array(1));
90 end
91 else
92 for i = 1:psz;
93 if ~isjava(cel{i})
94 chr{i} = builtin('char',cel{i});
95 else
96 chr{i} = toChar(cel{i});
97 end;
98 end;
99 end;
100
101 chr=char(chr);
Other subfunctions in this file are not included in this listing.