A variational problem for nematic liquid crystals with variable degree of orientation