Info

This question is closed. Reopen it to edit or answer.

I'm trying to have the first while loop run for each iteration of i, but don't know how to implement it, thoughts?

1 view (last 30 days)
for i=1:length(RET);
for j=1:length(RelRough);
%while %this is the while loop I'm stuck on
while error > 1e-14
FCT_cal=1./(-2.0*log10((RelRough(j)./3.7)+(2.51./(RET(i).*sqrt(FCT_guess))))).^2
error_new=abs(FCT_cal(i,j)-FCT_guess(i,j))
error = error_new
FCT_guess = FCT_cal
d=d+1
if d>30
disp('The program failed to converge in the allowable number of iterations.')
break
end
FCT(i(p),j(p)) = [FCT_cal]
end
end
  1 Comment
dpb
dpb on 19 Nov 2017
Besides the i loop you've also got the while inside another j loop???
But, presuming the convergence ever does occur, you need a line to reset the value of error to something greater than the convergence before the beginning of the while in order for it to execute.

Answers (0)

Community Treasure Hunt

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

Start Hunting!