How to break a code when conditions are met

2 views (last 30 days)
DIP
DIP on 8 Feb 2017
Commented: DIP on 8 Feb 2017
So I have a code with 2 numerical methods - backward euler and Runge kutta. What I want to do is create a program that calculates both numerical methods for a simple ODE and then stops when the difference between the two methods is 10e-5. The RK method is set for 11 iterations. The backward euler should end at approx 7380 iterations. How can this be done ?
  1 Comment
DIP
DIP on 8 Feb 2017
how do I know when should I stop iterations for the backward euler ??

Sign in to comment.

Answers (1)

KSSV
KSSV on 8 Feb 2017
Edited: KSSV on 8 Feb 2017
doc break
for i = 1:100
if i==7 % a condition
disp('I am exiting')
break
end
end
  3 Comments
DIP
DIP on 8 Feb 2017
unfortunately it did not. The ODE is dC/dx=C*S/U .

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!