You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LoadAsciiAttributes.m 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. function [attributes] = LoadAsciiAttributes(dataFilePath, dataFileName, numNodes, debug, debugPath)
  2. if nargin >= 3
  3. if nargin < 4
  4. debug = 0;
  5. end
  6. if nargin < 5
  7. debugPath = 'debug/';
  8. end
  9. dataFullName = strcat(dataFilePath,dataFileName);
  10. outFullPath = strcat(dataFilePath, debugPath);
  11. outFullName = strcat(outFullPath,dataFileName);
  12. if isdir(outFullPath) == 0 && debug == 1
  13. mkdir(outFullPath);
  14. end
  15. data = load(dataFullName);
  16. m = size(data,1);
  17. n = size(data,2);
  18. if m ~= numNodes
  19. fprintf('LoadAsciiAttributes - Invalid size: expecting %d, got %d\n',numNodes,m);
  20. return;
  21. end
  22. attributes = zeros(numNodes,n-1);
  23. for line=1:m
  24. id = data(line,1)+1;
  25. for col=2:n
  26. attributes(id,col-1) = data(line,col);
  27. end
  28. end
  29. if debug == 1
  30. save(strcat(outFullName,'.att.mat'), 'attributes');
  31. SaveIntMatrixToFile(strcat(outFullName,'.att.txt'), attributes);
  32. end
  33. else
  34. fprintf('Invalid parameters. expecting: dataFilePath, dataFileName, numNodes\n');
  35. end