  Using $\Delta\chi^2$ which is defined by the difference of the number of
events with the CP phase $\delta$ and the hypothetical one with $\delta=0$, we
discuss correlations of errors of the CP phase and other oscillation parameters
as well as the matter effect in measurements at neutrino factories. By varying
the oscillation parameters and the normalization of the matter effect, we
evaluated the data size required to reject a hypothesis with $\delta=0$ at
3$\sigma$CL. The optimum muon energy and the baseline depends on the magnitude
of $\theta_{13}$, the background fraction, the uncertainty of the normalization
of the matter effect, but in general lie in the ranges 20GeV $\lesssim
E_\mu\lesssim$ 50GeV, 1000km$\lesssim L\lesssim$3000km. If we assume that the
uncertainty of the matter effect is as large as 20% then the optimum values may
be modified to $E_\mu\lesssim$ 10GeV, $L\lesssim$1000km due to the strong
correlation of $\delta$ and the matter effect. We show analytically that
sensitivity to CP violation is lost for $E_\mu\ll$ 10GeV or for $E_\mu\gg$
50GeV. We also discuss the possibility of measuring CP violation at the
upgraded JHF experiment by taking all the error correlations into account, and
show that it is possible to demonstrate $\delta\ne0$ at 3$\sigma$CL for
$\theta_{13}\gtrsim 3^\circ$.
