0001 function d = pr_ev_diff(ev_tc, diff_func, varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 if nargin < 2
0017 diff_func = '';
0018 end
0019 if isempty(diff_func)
0020 diff_func = 'max';
0021 end
0022
0023 [m n] = size(ev_tc);
0024 d = zeros(1, n);
0025 switch lower(diff_func)
0026 case 'max'
0027 d = max(ev_tc, [], 1);
0028 case 'max-min'
0029 d = max(ev_tc, [], 1) - min(ev_tc, [], 1);
0030 case 'abs max'
0031 [d i] = max(abs(ev_tc), [], 1);
0032 for s = 1:n, d(s) = ev_tc(i(s), s); end
0033 case 'abs max-min'
0034 mx = max(ev_tc, [], 1);
0035 mn = min(ev_tc, [], 1);
0036 i = abs(mx) > abs(mn);
0037 d(i) = mx(i)-mn(i);
0038 d(~i) = mn(~i)-mx(~i);
0039 case 'window'
0040 if nargin < 4, error('Need window and dt'); end
0041 w = round(varargin{1} / varargin{2}) + 1;
0042 d = mean(ev_tc(w(1):w(2), :), 1);
0043 otherwise
0044 error(sprintf('What is this difference function: %s?', diff_func));
0045 end