what is the MATLAB function to evaluate ncr value when n is real

29 次查看(过去 30 天)
what is the MATLAB function to evaluate ncr value when n is real
  6 个评论
Walter Roberson
Walter Roberson 2018-8-25
What numeric values do you expect for the cases nCr(0.5,2) and nCr(-3,2) ? Number of combinations is only defined for positive integers.

请先登录,再进行评论。

采纳的回答

Kaushik Lakshminarasimhan
If n and r are both non-negative integers, and n >= r, use:
nCr = nchoosek(n,r)
If n and/or r can be negative, you can use the more general form:
nCr = gamma(n+1)/(gamma(r+1)*gamma((n-r)+1))
If either n or r is an integer <= -1, then the nCr is not defined.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 NaNs 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by