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.

CombineDataWithAttributes4.m 702B

5 years ago
1234567891011121314151617181920212223
  1. function [dataWithAtt, totalAttNum] = CombineDataWithAttributes4(data, attData)
  2. totalAttNum = size(attData,2);
  3. sizeWithAtt = totalAttNum + size(data,1);
  4. dataWithAtt = sparse(sizeWithAtt, sizeWithAtt);
  5. dataWithAtt(totalAttNum+1:end,totalAttNum+1:end) = data;
  6. dataLines = size(data,1);
  7. attLines = size(attData,1);
  8. if (attLines ~= dataLines)
  9. fprintf('CombineDataWithAttributes - Invalid data sizes: data %d, attributes %d\n',dataLines,attLines);
  10. end
  11. for line=1:dataLines
  12. nnzAtt = find(attData(line,:));
  13. for att = nnzAtt
  14. dataWithAtt(totalAttNum+line,att)=1;
  15. dataWithAtt(att,totalAttNum+line)=1;
  16. end
  17. end
  18. dataWithAtt = sparse(dataWithAtt);