This is a static copy of a profile reportHome
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)
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
32 | newfield=strcat(field,'.',n{i}... | 1938 | 0.514 s | 43.9% |  |
34 | eval(sprintf('arg=isstruct(b.%... | 2028 | 0.284 s | 24.3% |  |
38 | eval(sprintf('s.%s=b.%s;',newf... | 1372 | 0.164 s | 14.0% |  |
23 | eval(sprintf('n=fieldnames(b.%... | 656 | 0.098 s | 8.4% |  |
29 | if (isempty(field)) | 2028 | 0.022 s | 1.9% |  |
All other lines | | | 0.087 s | 7.5% |  |
Totals | | | 1.170 s | 100% | |
Children (called functions)
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
strcat | function | 1938 | 0.503 s | 43.0% |  |
mergestruct | function | 656 | 0 s | 0% |  |
Self time (built-ins, overhead, etc.) | | | 0.667 s | 57.0% |  |
Totals | | | 1.170 s | 100% | |
Code Analyzer results
No Code Analyzer messages.Coverage results
[ Show coverage for parent directory ]
Total lines in function | 40 |
Non-code lines (comments, blank lines) | 16 |
Code lines (lines that can run) | 24 |
Code lines that did run | 23 |
Code lines that did not run | 1 |
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