GetMaxDispersion.m 905 B

12345678910111213141516171819202122232425262728293031
  1. % GetMaxDispersion.m
  2. %
  3. % This function gets 2 vector lists as input and returns the maximum dispersion
  4. % for an input vector in comparison with the second vector list.
  5. %
  6. % input:
  7. % vecList1 - list of vectors to iterate through
  8. % vecList2 - (optional) list of vectors to use for dispersion
  9. %
  10. % output:
  11. % maxDisp - maximum dispersion
  12. % index1 - pointer to the element in the vecList1 with maxDisp
  13. % index2 - pointer to the element in the vecList2 with maxDisp
  14. function [maxDisp, index1, index2] = GetMaxDispersion(vecList1, vecList2)
  15. if (nargin < 2)
  16. vecList2 = vecList1;
  17. end
  18. maxDisp = 0;
  19. index = -1;
  20. for ind=1:size(vecList1)
  21. [dispersion, tmpInd] = GetDispersion(vecList1(ind,:), vecList2);
  22. if (dispersion > maxDisp)
  23. maxDisp = dispersion;
  24. index1 = ind;
  25. index2 = tmpInd;
  26. end
  27. end
  28. end