wolffd@0: function Y = scale_ratings(Y, max_weight) wolffd@0: % [Yout, Xout] = scale_ratings(Y, max_weight) wolffd@0: wolffd@0: wolffd@0: % get maximal weight wolffd@0: weights = cell2mat(Y(:,3)); wolffd@0: max_dataweight = max(weights); wolffd@0: wolffd@0: valid = ~(cellfun(@isempty, Y(:,1)) | cellfun(@isempty, Y(:,2))); wolffd@0: wolffd@0: % scale weights to a maximal value of max_weight wolffd@0: for i = 1:size(Y, 1) wolffd@0: if valid(i) && Y{i,3} > 0 wolffd@0: Y{i,3} = min(max_weight, max(1, round((Y{i,3} / max_dataweight) * max_weight))); wolffd@0: end wolffd@0: end