MATLAB: Can any one help me in detecting an error in matlab code please

**

pih=[];
for im=1:0.1:20
n=15;
i=13;
k=8;
m=2;
h=3;
f=factorial(n)/(factorial(i)*factorial(n-i));
g=factorial((2^(k-(m*h)))*factorial(i)*factorial((2^(k-(m*h)))-i));
p=factorial((2^k))/factorial(i)*factorial((2^k)-i);
j=g/p;
o=factorial((2^k)-(2^(k-(m*h))))/factorial(n-i)*factorial((2^k) ...
-(2^(k-(m*h)))-(n-i));
u=factorial((2^k)-i)/factorial(n-i)*factorial((2^k)-i-(n-i));
z=o/u;
pih=f*j*z;
end
this is the code and this is the error message :
??? Error using ==> factorial at 17
N must be a matrix of non-negative integers.
Error in ==> marwa at 12
g=factorial((2^(k-(m*h)))*factorial(i)*factorial((2^(k-(m*h)))-i));
??? Error using ==> factorial at 17
N must be a matrix of non-negative integers.
Error in ==> marwa at 12
g=factorial((2^(k-(m*h)))*factorial(i)*factorial((2^(k-(m*h)))-i));

Best Answer

The error message is telling you what is wrong. In this case the expression within the larger expression for finding g
factorial((2^(k-(m*h)))-i)
when the values of k, m, h, and i are substituted amounts to
factorial(-9)
and minus nine is not a value the factorial function can handle, as the error message indicates.
You need to rethink your code and decide what really belongs there.