


RESETINTEGRATOR Running counter with resets. OUTPUT = RESETINTEGRATOR(INPUT, RESET), where INPUT and RESET are length N vectors, returns a length N vector OUTPUT equal to the cumulative sum of INPUT, reset to zero on each sample k for which RESET(k) == 0. OUTPUT = RESETINTEGRATOR(INPUT) uses INPUT as the RESET vector; it is equivalent to OUTPUT = RESETINTEGRATOR(INPUT, INPUT).


0001 function output = resetintegrator(input, reset) 0002 %RESETINTEGRATOR Running counter with resets. 0003 % OUTPUT = RESETINTEGRATOR(INPUT, RESET), where INPUT and RESET are 0004 % length N vectors, returns a length N vector OUTPUT equal to the 0005 % cumulative sum of INPUT, reset to zero on each sample k for which 0006 % RESET(k) == 0. 0007 % 0008 % OUTPUT = RESETINTEGRATOR(INPUT) uses INPUT as the RESET vector; it 0009 % is equivalent to OUTPUT = RESETINTEGRATOR(INPUT, INPUT). 0010 0011 if (nargin < 2), reset = input; 0012 elseif (length(input) ~= length(reset)), 0013 error('INPUT and RESET vectors must be of the same length.'); 0014 end; 0015 if (isempty(input)), output = zeros(size(input)); return; end; % trap special case 0016 0017 output = CORE_resetintegrator(double(input), logical(reset));