This is a static copy of a profile report

Home

mergestruct (683 calls, 1.170 sec)
Generated 05-Aug-2011 13:01:02 using cpu time.
function in file /home/LeechJ/cbass_analysis/matutils/mergestruct.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
framecutfunction9
mergestructfunction656
cutObsfunction18
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
32
newfield=strcat(field,'.',n{i}...
19380.514 s43.9%
34
eval(sprintf('arg=isstruct(b.%...
20280.284 s24.3%
38
eval(sprintf('s.%s=b.%s;',newf...
13720.164 s14.0%
23
eval(sprintf('n=fieldnames(b.%...
6560.098 s8.4%
29
if (isempty(field))
20280.022 s1.9%
All other lines  0.087 s7.5%
Totals  1.170 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
strcatfunction19380.503 s43.0%
mergestructfunction6560 s0%
Self time (built-ins, overhead, etc.)  0.667 s57.0%
Totals  1.170 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
[ Show coverage for parent directory ]
Total lines in function40
Non-code lines (comments, blank lines)16
Code lines (lines that can run)24
Code lines that did run23
Code lines that did not run1
Coverage (did run/can run)95.83 %
Function listing
   time   calls  line
1 function s=mergestruct(s,b,field)
2
3 % function s=mergestruct(s,b)
4 %
5 % merges the fields of structure b into struct s. it will only do it
6 % for fields of b that is not present in s.
7 %
8 % For example:
9 % s(i).a.b.c to s.a.b.c(i)
10 %
11 %Author: Michael Loh
12
13
0.01 683 14 if (~isstruct(b))
1 15 return
16 end
17
0.02 682 18 if (nargin==2)
26 19 field=[];
26 20 end
21
682 22 if (~isempty(field))
0.10 656 23 eval(sprintf('n=fieldnames(b.%s);',field));
26 24 else
26 25 n=fieldnames(b);
26 26 end
27
0.02 682 28 for i=1:length(n)
0.02 2028 29 if (isempty(field))
90 30 newfield=n{i};
0.01 1938 31 else
0.51 1938 32 newfield=strcat(field,'.',n{i});
1938 33 end
0.28 2028 34 eval(sprintf('arg=isstruct(b.%s);',newfield));
2028 35 if (arg)
656 36 s=mergestruct(s,b,newfield);
1372 37 else
0.16 1372 38 eval(sprintf('s.%s=b.%s;',newfield,newfield));
1372 39 end
2028 40 end