function [attData, totalAttNum] = PreProcessDataAttributes4(data, attributes, attUpperRange, selectedAttInx)

totalAttNum = sum(attUpperRange(selectedAttInx));
attData = zeros(size(data,1), totalAttNum);

numAttTypes = size(selectedAttInx,2); %size(attUpperRange,2);
attOffsets = zeros(numAttTypes,1);

if (numAttTypes>1)
    for i=2:numAttTypes
        attOffsets(i) = attOffsets(i-1)+attUpperRange(selectedAttInx(i-1));
    end
end

dataLines = size(data,1);
attLines = size(attributes,1);
if (attLines ~= dataLines)
        fprintf('CombineDataWithAttributes - Invalid data sizes: data %d, attributes %d\n',dataLines,attLines);
end

for line=1:dataLines
    for att=1:numAttTypes
        value = attributes(line,selectedAttInx(att));
        if value > 0
            attData(line,attOffsets(att)+value)=1;
        end
    end
end
    
%attData = sparse(attData);

end %function

