function LUT = step2_assignment(S, k, LUT, M)
    m = size(S, 1);
    for i = 1:m
        d = zeros(1,k);
        for j = 1:k
            d(j) = sum((S(i,:)-M(j,:)).^2);
        end
        [~, min_d] = min(d);
        LUT(i) = min_d;
    end
end
