Please help! Am trying to find c(n)

2 visualizzazioni (ultimi 30 giorni)
pattira sripacharasakullert
Commentato: Walter Roberson il 17 Apr 2021
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?

Risposte (1)

Walter Roberson
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)
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
k = 1×4
1 2 3 4
Array indices must be positive integers or logical values.
I converted your formula to sum() for you, but I deliberately did not fix the problem with your what you are summing.
  5 Commenti
pattira sripacharasakullert
I'm sorry to make you feel confused. My problem is as below:
When I choose n=2, I will get c(3) like this,
So, I finish calculating the value c(3). Next, c(4) is calculated the same way by substituting n=3. The goal is only to find the value of each c(1), c(2), c(3),...,c(100).
Walter Roberson
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

Accedi per commentare.

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by