I wrote the code for the following recursive formula but my answer is not correct.Can any one tell me mistake and do the correction .If any correction mention in detail .

1 vue (au cours des 30 derniers jours)
C(i,j+1)=D_0*(k+2)*(k+1)*C(k+2,h)+2*D_0*a*(summ(r=0 to k)(sum(s=0 to h)delta(r-1,h-s)*(k-r+1)*(k-r+2)*C(k-r+2,s)+a*D_0*a*(summ(r=0 to k)(sum(s=0 to h)delta(r-2,h-s)*(k-r+1)*(k-r+2)C(k-r+2,s)+a*(k+1)*C(k+1,h)+b*(summ(r=0 to k)(sum(s=0 to h)delta(r-1,h-s)*(k-r+1)*C(k-r+2,s)-A*C(k,h) Initial value are C(0,0)=C1+C2; C(k,0)=(-1d)^(k)/factorial(k) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% the code is as follows C=zeros(200,200); series(x,t)=sym(zeros(1,1));
for k=2:1:200 C(1,1)=c_1+c_2; C(k,1)=(((-ALPHA)^(k-1))*c_2)/factorial(k-1); end
for h=1:1:15 for k=1:1:15
S=0; T=0; R=0; % for double summation ..............
for r=1:1:k
for s=1:1:h
% for dirac delta .................
if r==2 && h+1-s==1 D=1; else D=0; end S =S+ D*(k-r+1)*(k-r+2)*C(k+3-r,s);
if r==3 && h+1-s==1 M=1; else M=0; end T =T + M*(k-r+1)*(k-r+2)*C(k+3-r,s);
if r==2 && h+1-s==1 N=1; else N=0; end R = R+ N*(k-r+1)*C(k+2-r,s);
end
end
% for main function...........
C(k,h+1) =((D_0*(k+1)*k*C(k+2,h))+(2*a*D_0*S)+(D*a*a*T)+((2*D_0*a-V_0)*k*C(k+1,h))+(((2*D_0*a*a)-(V_0*a))*R)-(V_0*a*C(k,h)))/h;
end
end
% for h=1:1:5 % for k=1:1:5 % series(x,t) = series(x,t) + (C(k,h)* (power(x,k-1)) * (power(t,h-1))); % end % end for h=1:1:150 for k=1:1:150
R=0; % for double summation ..............
for r=1:1:k
for s=1:1:h
% for dirac delta .................
if r==2 && h+1-s==1
N=1;
else
N=0;
end
R = R+ N*(k-r+1)*C(k+2-r,s);
end
end
% for main function...........
C(k,h+1) = (D_0 *(k+1)* k * C(k+2,h) -V_0*a * R - V_0 * k * C(k+1,h)-(a*V_0*C(k,h)))/h;
end
end
R
% for h=1:1:50
% for k=1:1:50
% series(x,t) = series(x,t) + (C(k,h)* (power(x,k-1)) * (power(t,h-1)));
% end
% end
% series
x1=0:0.1:1 t1=0:0.1:1 for k=1:10% loop for value of x. if you change the x1 dimension the make change here also x=x1(1,k); for m=1:10%loop for vlaue of t. if you change the the t1 dimension then make change here also sumt=0; sum1=0; t=t1(1,m); for i=1:50 % it will consider the 30 rows from the coefficient table T_c(k,h) b=0; for j=1:10% it will consider the 30 columns from coefficient table T_h(k,h) b=b+C(j,i)*power(x,j-1) ; end c=b*power(t,i-1); sum1=sum1+c; end sum1 ; sumt=sumt+sum1 % display T_c value according to t final(k,m) = sumt;%w.r.t distance final1(m,k)=sumt; % w.r.t time end fprintf('============')
end
  1 commentaire
John D'Errico
John D'Errico le 15 Juin 2017
Modifié(e) : John D'Errico le 15 Juin 2017
Your mistake is in thinking that anyone in the universe can help you with this, given the information provided.
https://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
You wrote messy, virtually undocumented code to do something (completely unknown what it is SUPPOSED to do), and that code does not work. How is anyone supposed to know how to fix your code, and not only that, give you a detailed explanation of how to fix it?
Do NOT write a huge mess of code, then hope that it will all work, testing it only at the end. Never do this, as it will always fail, leaving you unable to know where the bug lies.
Learn to write code SLOWLY. Do it one piece at a time. Verify that each fragment does EXACTLY what you want it to do. You may be able to write it as modular code, thus small functions that can be debugged completely. Document each piece as you do it. Then put it all together at the end. If each fragment does what it was written to do, then so will the whole.
You should also learn how to insert code so that it will be readable. What you have here is not so.
https://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup#answer_18099

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by