function buf = write_rank_slot_to_id_slot(buf, target_id, px, py, n, mu, unk, L)

switch target_id
    case 1
        buf(1:L)     = px;
        buf(L+1:2*L) = py;
        buf(2*L+1)   = n;
        buf(6*L+6)   = mu;
        buf(6*L+9)   = unk;

    case 2
        buf(2*L+2:3*L+1) = px;
        buf(3*L+2:4*L+1) = py;
        buf(4*L+2)       = n;
        buf(6*L+7)       = mu;
        buf(6*L+10)      = unk;

    case 3
        buf(4*L+3:5*L+2) = px;
        buf(5*L+3:6*L+2) = py;
        buf(6*L+3)       = n;
        buf(6*L+8)       = mu;
        buf(6*L+11)      = unk;
end

end