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.

AddAttArff.m 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. % function AddAttArff:
  2. %
  3. % This function adds the data and the name of the new attribute to the initial
  4. % data as a new column.
  5. %
  6. % input:
  7. % data - data of the initial arff file
  8. % attributes - attributes of the initial arff file
  9. % attData - attribute data to append at the data. When nominal attributes
  10. % are appended the attribute values should corespond to the enumeration
  11. % equivalent
  12. % attName - attribute name
  13. % attType - attribute type (Integer, Numeric or nominal in the form '{val1,val2}')
  14. %
  15. % output:
  16. % newData - data after addition of the new column
  17. % newAttributes - attributes containing the addition of the new attribute
  18. function [newData, newAttributes] = AddAttArff(data, attributes, attData, attName, attType)
  19. % are data and new attribute smae size
  20. assert(size(data,1)==size(attData,1), 'Provided attribute does not have same number of entries as initial data');
  21. % check if attribute already exists
  22. for i=1:size(attributes,1)
  23. if (strcmpi(attributes{i,1}, attName))
  24. error(['Attributes "' attName '" already exists in file ' arffFile]);
  25. end
  26. end
  27. % merge returned attributes
  28. newAttributes = attributes;
  29. index = size(attributes,1)+1;
  30. newAttributes{index,1} = attName;
  31. newAttributes{index,2} = attType;
  32. % concatenate attribute to the returned data
  33. newData = zeros(size(data,1), size(data,2)+1);
  34. newData(:,1:end-1) = data(:,:);
  35. newData(:,end) = attData(:);
  36. end