# Excel's CHIDIST function in MATLAB

How to reproduce MS Excel's CHIDIST function in MATLAB?

Returns the one-tailed probability of the chi-squared distribution. The χ2 distribution is associated with a χ2 test. Use the χ2 test to compare observed and expected values. For example, a genetic experiment might hypothesize that the next generation of plants will exhibit a certain set of colors. By comparing the observed results with the expected ones, you can decide whether your original hypothesis is valid.

Syntax

CHIDIST(x,degrees_freedom)

X is the value at which you want to evaluate the distribution.

Degrees_freedom is the number of degrees of freedom.

So, if I have column of numbers as x and use the formula like =CHIDIST(A1:A60,3), it returns 1 number.

I have tried to follow two advices from this thread, but I always get a vector of numbers, not one number.

Thanks

-
CHIDIST, like many Excel functions, works when applied to arrays: it threads over the array in this case and returns one value for each of the 60 cells in the range a1:a60. (Tested with Excel 2002.) If you do not enter it as an array function, the value you are getting is the first value: in this case, it will equal CHIDIST(A1, 3). –  whuber Jun 20 '11 at 21:32
Yes, I already found my mistake. Thanks. –  yuk Jun 21 '11 at 1:12
Are you sure you're using the correct function? CHIDIST in excel takes a single number, not an array. chidist(a1:a60,3) doesn't make sense in this case.
CHIDIST(x,df) (in Excel)