How to find factorial(c) of an array of numbers?

2 次查看(过去 30 天)
Respected all
I have successfully got the values for j and v. I have got stuck in solving t due to the problem in finding factorial(c). My question is how to code for factorial term in the expression? Is it possible or I am on the wrong path? As without solving factorial, t cannot be determined. What should I do?
Code attached:
A = linspace(1,10)
C = linspace(1, 11)
[k, c] = ndgrid(A, C)
j=gammainc(c,(0.85));
v=gamma(c.^(-1));
t=0.85.*(1-(((0.85).^5.*(1-(((0.85))./(1-(((0.85)).^6)))))).*1.*(1-((0.85).^5.*(factorial(c)).^-1.*(c.^(5-c).^-1)./(exp(0.85).*k.*v+(0.85).^c.*(1-(0.85./c).^(5-c+1)))/factorial(c).*(1-(0.85./c)))));
The following error is being encountered
Error using factorial
N must be an array of real non-negative integers.
How can this error be removed?
Please help
Regards
Surabhi

采纳的回答

Adam Danz
Adam Danz 2020-5-26
编辑:Adam Danz 2020-5-26
N must be an array of real non-negative integers.
To troubleshoot that error message, let's go through the list of possibilities.
% Is c an array or real numbers?
all(isreal(c(:))) % = 1, true
% Is c all non-negative?
all(c(:)>=0) % = 1, true
% Is c all integers?
all(isinteger(c(:))) % = 0! FALSE
There's the problem. C contains non-integers. It makes sense that this would cause an error, right? Factorials are functions of intergers.
factorial(3) = 24
4 * 3 * 2 * 1 = 24
How could that be done with non-integers?
  9 个评论
Adam Danz
Adam Danz 2020-5-27
Glad I could help. If you get stuck again with this topic, leave a comment to loop me back in.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by