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

2 ビュー (過去 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 Center および File ExchangeGet 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