GetAttPositionArff.m 946 B

1234567891011121314151617181920212223242526272829303132
  1. % function GetAttPositionArff:
  2. %
  3. % Gets a list of attributes returned from LoadArff and an attribute name to
  4. % search. If it finds the attribute returns its index otherwise it can raise
  5. % an error.
  6. %
  7. % input:
  8. % arffAttributes - attribute list returned from LoadArff
  9. % attribute - attribute to search
  10. % check - (optional) boolean to check if attribute exists. Default is true
  11. %
  12. % output:
  13. % attIndex - index attribute of the attribute in the list if it was found.
  14. % Returns 0 if it wasn't found
  15. function [attIndex] = GetAttPositionArff(arffAttributes, attribute, check)
  16. if (nargin < 3)
  17. check = true;
  18. end
  19. attIndex = 0;
  20. for i=1:size(arffAttributes,1)
  21. if (strcmpi(arffAttributes{i,1}, attribute) == 1)
  22. attIndex = i;
  23. end
  24. end
  25. % check index
  26. if (check)
  27. assert(attIndex>0, ['Attribute "' attribute '" not found']);
  28. end
  29. end