필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
surabhi sachdeva
surabhi sachdeva 2020년 5월 26일
댓글: surabhi sachdeva 2020년 5월 27일
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.
surabhi sachdeva
surabhi sachdeva 2020년 5월 27일
Thank you sir
Regards

댓글을 달려면 로그인하십시오.

추가 답변 (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