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.

qfind.m 766 B

12345678910111213141516171819202122232425262728293031323334353637
  1. function ys = qfind(x,ts)
  2. % function y= stats.qfind(x,ts)
  3. % x is a vector , t is the target (can be one or many targets),
  4. % y is same length as ts
  5. % does a binary search: assumes that x is sorted low to high and unique.
  6. ys=zeros(size(ts));
  7. for i=1:length(ts)
  8. t=ts(i);
  9. if isnan(t)
  10. y=nan;
  11. else
  12. high = length(x);
  13. low = 0;
  14. if t>=x(end)
  15. y=length(x);
  16. else
  17. try
  18. while (high - low > 1)
  19. probe = ceil((high + low) / 2);
  20. if (x(probe) > t)
  21. high = probe;
  22. else
  23. low = probe;
  24. end
  25. end
  26. y=low;
  27. catch
  28. y=low;
  29. end
  30. end
  31. end
  32. ys(i)=y;
  33. end