This is a static copy of a profile report

Home

detrend (36 calls, 0.743 sec)
Generated 05-Aug-2011 13:00:52 using cpu time.
function in file /usr/local/MATLAB/R2011a/toolbox/matlab/datafun/detrend.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
flagRFI_stdfunction36
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
45
y = x - a*(a\x);		% Remove bes...
360.700 s94.1%
43
a((1:M)+bp(kb),kb) = (1:M)'/M;
360.011 s1.5%
37
bp = unique([0;double(bp(:));N...
360.011 s1.5%
54
if n == 1
360 s0%
44
end
360 s0%
All other lines  0.022 s2.9%
Totals  0.743 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
uniquefunction360.011 s1.5%
Self time (built-ins, overhead, etc.)  0.732 s98.5%
Totals  0.743 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
[ Show coverage for parent directory ]
Total lines in function56
Non-code lines (comments, blank lines)30
Code lines (lines that can run)26
Code lines that did run17
Code lines that did not run9
Coverage (did run/can run)65.38 %
Function listing
   time   calls  line
1 function y = detrend(x,o,bp)
2 %DETREND Remove a linear trend from a vector, usually for FFT processing.
3 % Y = DETREND(X) removes the best straight-line fit linear trend from the
4 % data in vector X and returns the residual in vector Y. If X is a
5 % matrix, DETREND removes the trend from each column of the matrix.
6 %
7 % Y = DETREND(X,'constant') removes just the mean value from the vector X,
8 % or the mean value from each column, if X is a matrix.
9 %
10 % Y = DETREND(X,'linear',BP) removes a continuous, piecewise linear trend.
11 % Breakpoint indices for the linear trend are contained in the vector BP.
12 % The default is no breakpoints, such that one single straight line is
13 % removed from each column of X.
14 %
15 % Class support for inputs X,BP:
16 % float: double, single
17 %
18 % See also MEAN
19
20 % Copyright 1984-2006 The MathWorks, Inc.
21 % $Revision: 1.9.4.4 $ $Date: 2010/08/23 23:07:35 $
22
36 23 if nargin < 2, o = 1; end
36 24 if nargin < 3, bp = 0; end
25
36 26 n = size(x,1);
36 27 if n == 1,
28 x = x(:); % If a row, turn into column vector
29 end
36 30 N = size(x,1);
31
36 32 switch o
36 33 case {0,'c','constant'}
34 y = x - ones(N,1)*mean(x); % Remove just mean from each column
35
36 36 case {1,'l','linear'}
0.01 36 37 bp = unique([0;double(bp(:));N-1]); % Include both endpoints
36 38 lb = length(bp)-1;
39 % Build regressor with linear pieces + DC
36 40 a = [zeros(N,lb,class(x)) ones(N,1,class(x))];
36 41 for kb = 1:lb
36 42 M = N - bp(kb);
0.01 36 43 a((1:M)+bp(kb),kb) = (1:M)'/M;
36 44 end
0.70 36 45 y = x - a*(a\x); % Remove best fit
46
47 otherwise
48 % This should eventually become an error.
49 warning(message('MATLAB:detrend:InvalidTrendType', num2str( o )));
50 y = detrend(x,1,bp);
51
52 end
53
36 54 if n == 1
55 y = y.';
56 end