Why can't Matlab do the factorial of a non-integer number?
11 views (last 30 days)
I tried using the factorial function on a number with decimals and got the following error: N must be an array of real non-negative integers.
Is there an alternative so that it can calculate the factorial of a number with decimals like Excel does?
Thanks for your time
Davide Masiello on 6 Feb 2022
Edited: Davide Masiello on 6 Feb 2022
MatLab 'factorial' is coded so to work with integers only.
The generalization of a factorial is the Γ function, which is
and the relation with the factorial is
MatLab implements the Γ function. Therefore, to compute the factorial of 1.5 you can write
Which yields 1.3293, the correct answer.