Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

I want the coding for double summationI wrote the following code but my answer is not correct.

1 visualizzazione (ultimi 30 giorni)
My whole formula is
C(k,h+1)=A*(k+1)*C(k+1,h)-B*C(k,h)+D*(k+2)*(k+1)C(k+2,h)+2*a*D*(summation(r=0 to k)summation (s=0 to h))Kroneckerdelta(r-1,h-s)*(k-r+1)*(k-r+2)C(k-r+2,s))+a*a*D*(summation(r=0 to k)summation (s=0 to h))Kroneckerdelta(r-2,h-s)*(k-r+1)*(k-r+2)C(k-r+2,s))
For kroneckerdelta i had separted defined a function which is as follows: function d = kronDel(i,j)
if i == j
d = 1;
else
d = 0;
end
Now first part ,i initial the value using for loop
n=10;
for i=1:1:n+5
C1(1,1)=0.030792+0.009208;
C1(i,1)=(0.009208*((-0.00000588235)^(i-1))/factorial(i-1));
end
the initial values are correct Now what i did was i broke my formula into parts and calculate the first three terms of my formula i.e. upto D*(k+2)*(k+1)*C(k+2,h)using the following for loop
for j=1:1:n+1
for i=1:1:n+1
C1(i,j+1)=((a*i*C1(i+1,j)-b*C1(i,j)+D1*i*(i+1)*C1(i+2,j)))/j;
end
end
Now i calculate the 4th term i.e.term containing Keonecker delta using the following loop
for i=1:1:n+1
for j=1:1:n+1
ab(i,j)=(2*a*D1* kronDel(i-1,j)*((n+1)-i+1)*((n+1)-i+2)*C1((n+1)-i+2,j))/j;
end
end
now this 4th term value is wrong.so i want the code for double summation. Check the pdf file aslo
in that k=0 to 100 h=0 to 100
you will get more clear idea I Think the logic is wrong in N+1 but i am not getting it.Kindly guide me

Risposte (1)

Torsten
Torsten il 3 Gen 2017
Modificato: Torsten il 3 Gen 2017
One hint:
Because of the kroneckerDelta's in both double summations, substitute r=h-s+1 in the first double summation and r=h-s+2 in the second double summation. This way, you are left with two single summations over s.
Best wishes
Torsten.

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by