Please help! Am trying to find c(n)
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
alpha=1;
for n=3:10
syms k
c(1)=1;
c(2)=1;
c(3)=2;
c(n+1) = symsum(c(n)*c(n-k)*gamma(1+n*alpha)/(gamma(1+(k-1)*alpha)*gamma(1+n*alpha-k*alpha+alpha)),k,1,n+1);
end
This is the error
Error using sym/subsindex (line 862)
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments must be symbolic variables, and function
body must be sym expression.
How do i deal with this problem?
0 Commenti
Risposte (1)
Walter Roberson
il 16 Apr 2021
k is a symbolic variable. You can never use a symbolic variable as part of an index, the way you do in c(n-k)
You are confusing formulas and arrays. Please read https://www.mathworks.com/matlabcentral/answers/395816-why-do-i-get-array-indices-must-be-positive-integers-or-logical-values-error-when-using-angle-fu#comment_882605
What you need to do is calculate the individual terms and then sum() them.
alpha=1;
c(1)=1;
c(2)=1;
c(3)=2;
for n=3:10
k = 1 : n + 1
c(n+1) = sum(c(n).*c(n-k).*gamma(1+n*alpha)./(gamma(1+(k-1).*alpha).*gamma(1+n.*alpha-k.*alpha+alpha)));
end
I converted your formula to sum() for you, but I deliberately did not fix the problem with your what you are summing.
5 Commenti
Walter Roberson
il 17 Apr 2021
Your diagram has but your code has and you have also not taken into account that is stored in
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!