Computing the Hausdorff dimension of subshifts using matrices