Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
surabhi sachdeva
surabhi sachdeva le 26 Mai 2020
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

Réponse acceptée

Adam Danz
Adam Danz le 26 Mai 2020
Modifié(e) : Adam Danz le 26 Mai 2020
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 commentaires
Adam Danz
Adam Danz le 27 Mai 2020
Glad I could help. If you get stuck again with this topic, leave a comment to loop me back in.
surabhi sachdeva
surabhi sachdeva le 27 Mai 2020
Thank you sir
Regards

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by