while loop convergence for sum
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dear all,
I'm using a while loop in order to find a value etapl iteratively. The code looks like follows where eta(:) is a first guess (which is close to the desired solution). For N=3 it seems to work but for N>5 the solution doesnt converge but jumps between two values. It doesnt appear to be an issue with the initial values X.
for jj=1:dp % looking for a number dp of etapl
etapl=eta(jj); %assign etapl to the first guess
eta_old=etapl+0.01; %introduce an error to go into the while loop
while abs(etapl-eta_old) > 0.001 % convergence criterion
eta_old = etapl;
sum_eta=0;
for n=2:2:N-1 % a sum from n=2,4,... to N-1 that contains etapl
sum_eta=sum_eta+sinh(n*pi/X(1)*(d+etapl))*(X(n)*...
cos(n*pi/X(1)*x(jj))+X(n+1)*sin(n*pi/X(1)*x(jj)));
end
etapl=Psi/(X(1)/T-U)-1/(X(1)/T-U)*sum_eta;
end
eta(jj)=etapl;
end
Any assistance is very much appreciated!
Kind regards,
2 commentaires
Star Strider
le 16 Déc 2014
What are T and U? Maybe I’m missing something, but I don’t see them in the code you posted. They might be important.
Réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements 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!