Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

conv2run.m 996 B

123456789101112131415161718192021222324252627282930313233343536
  1. function f = conv2run(a,b,c)
  2. % function f = conv2run(a,b,c)
  3. %
  4. % <a> is a 2D matrix with time x cases
  5. % <b> is a column vector with time x 1
  6. % <c> is a column vector with the same number of rows as <a>.
  7. % elements should be positive integers.
  8. %
  9. % convolve <a> with <b>, returning a matrix the same size as <a>.
  10. % the convolution is performed separately for each group indicated
  11. % by <c>. for example, the convolution is performed separately
  12. % for elements matching <c>==1, elements matching <c>==2, etc.
  13. % this ensures that there is no convolution bleedage across groups.
  14. %
  15. % this function is useful for performing convolutions for multiple
  16. % runs (where time does not extend across consecutive runs).
  17. %
  18. % example:
  19. % a = [1 0 0 4 0 0 1 0 0 0 0]';
  20. % b = [1 1 1 1 1]';
  21. % c = [1 1 1 2 2 2 3 3 3 3 3]';
  22. % f = conv2run(a,b,c);
  23. % [a f]
  24. % calc
  25. blen = length(b);
  26. % init
  27. f = zeros(size(a),class(a));
  28. % loop over cases
  29. for p=1:max(c)
  30. temp = conv2(a(c==p,:),b);
  31. f(c==p,:) = temp(1:end-blen+1,:);
  32. end