MATLAB: Finding probability for chi square distribution

chi squaredMATLAB

For a random variable X, which is chi square distributed with D degrees of freedom and P proportionality factor, how can we find x using MATLAB such that P(X>x)=0.001?
I have tried using chi2cdf, but could not understand how the command works exactly.

Best Answer

x = chi2inv(1-0.001,D)