How to break a code when conditions are met

조회 수: 2 (최근 30일)
DIP
DIP 2017년 2월 8일
댓글: DIP 2017년 2월 8일
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
DIP
DIP 2017년 2월 8일
how do I know when should I stop iterations for the backward euler ??

댓글을 달려면 로그인하십시오.

답변 (1개)

KSSV
KSSV 2017년 2월 8일
편집: KSSV 2017년 2월 8일
doc break
for i = 1:100
if i==7 % a condition
disp('I am exiting')
break
end
end
  댓글 수: 3
KSSV
KSSV 2017년 2월 8일
What is the question? Did it work?
DIP
DIP 2017년 2월 8일
unfortunately it did not. The ODE is dC/dx=C*S/U .

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by