MATLAB: Factorial function won’t take a cell argument independently of it’s class (double, integer, etc)

cellcell arraysconversiondoublefactorialuint16

i can't calculate the factorial of a cell element (being it an array), though it is double (checked it with class funct.) and factorial doing fine with a double array… and neither it works using int16 or uint16 conversions on the cell element (called bins {1}) it simply states that "N must be a matrix of non-negative integers." and i do give it such thing.

Best Answer

This is because of your MATLAB version. Here using MATLAB 2010b:
>> factorial(uint16([3.4 2.8]))
??? Error using ==> factorial at 17
N must be a matrix of non-negative integers.
>> factorial(round([3.4 2.8]))
ans =
6 6
The second line of code actually throws an error for this case:
~isa(N,'double')
which you would have found by simply clicking on the error message link.