It doesn’t because fitting the chi-square distribution is generally not recommended. The chi-square distribution is used to describe the distribution of parameters, not data. At least that’s how I understand it.
However if you must, this comes close:
V = 10;
R = chi2rnd(V, 1, 100);
X = histcounts(R,20);
RNCF = @(v) norm(X - chi2pdf((1:length(X)),v));
Ve = fminsearch(RNCF, rand);
plot((1:length(X)), chi2pdf((1:length(X)),Ve), '-r')
Experiment to get the result you want.