This is a static copy of a profile reportHome
bitsearch (1 call, 0.011 sec)
Generated 05-Aug-2011 13:01:32 using cpu time.
function in file /home/LeechJ/cbass_analysis/reduc/bitsearch.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 |
37 | ind=bitand(uint32(v),uint32(ma... | 1 | 0.011 s | 100.0% |  |
38 | ind=ind==mask; | 1 | 0 s | 0% |  |
36 | case {'all','any'} | 1 | 0 s | 0% |  |
33 | case 'only' | 1 | 0 s | 0% |  |
32 | switch logical | 1 | 0 s | 0% |  |
All other lines | | | 0 s | 0% |  |
Totals | | | 0.011 s | 100% | |
Children (called functions)
No childrenCode Analyzer results
Line number | Message |
22 | Use && instead of & as the AND operator in (scalar) conditional statements. |
Coverage results
[ Show coverage for parent directory ]
Total lines in function | 42 |
Non-code lines (comments, blank lines) | 21 |
Code lines (lines that can run) | 21 |
Code lines that did run | 14 |
Code lines that did not run | 7 |
Coverage (did run/can run) | 66.67 % |
Function listing
time calls line
1 function ind=bitsearch(v,bit,logical)
2
3 % function ind=bitsearch(v,bit,logical)
4 %
5 % v - Nx1 or 1xN vector
6 % bit - bits to search for. For multiple bits, input as array
7 % logical - 'only' -> for elements of v that only contains bit value, bits
8 % - 'all' or 'any' -> for elements of v that contains any of the bit
9 % values in bits
10 %
11 % ind=bitsearch(d.array.frame.features,[1 2], 'all')
12 %
13 % this extracts all features containing both bits f1 and f2 regardless of
14 % what other features bits are set.
15 %
16
17 % v must be Nx1 or 1xN vector
1 18 if (ndims(v)>2)
19 error('Argument ''v'' must be a Nx1 or 1xN vector')
1 20 else
1 21 [a,b]=size(v);
1 22 if (a~=1 & b~=1)
23 error('Argument''v'' must be a Nx1 or 1xN vector')
24 end
1 25 end
26
1 27 mask=0;
1 28 for i=1:length(bit)
1 29 mask=mask+2^bit(i);
1 30 end
31
1 32 switch logical
1 33 case 'only'
34 ind=v==mask;
35
1 36 case {'all','any'}
0.01 1 37 ind=bitand(uint32(v),uint32(mask));
1 38 ind=ind==mask;
39
40 otherwise
41 error('Invalid ''logical'' argument')
42 end