필터 지우기
필터 지우기

odeevent

조회 수: 3 (최근 30일)
Rose
Rose 2011년 4월 20일
Hi there,
I have an odeevent sub-routine:
function [x,isterm,dir] = odeevent(~,y,k1,k2,k3,mu,d1,d2,r,K,k,alpha,gamma,n)
dy = funl2([],y,k1,k2,k3,mu,d1,d2,r,K,k,alpha,gamma,n);
x = norm(dy) - 1e-3;
isterm = 1;
dir = 0;
this works well. But in addition to this norm condition, i want to apply another condition too, viz
y(2)+y(3)<10
isterm=1;
I want the program to work like:
If the norm condition is satisfied then the code should stop. Otherwise if the second condition is satisfied then the program should stop. I don't know how to put it into MATLAB language. Can someone help me out! Thanks a lot in advance!!

답변 (1개)

Walter Roberson
Walter Roberson 2011년 4월 20일
I am not clear what your norm condition is. Is it norm(dy) < 1E-3 ?
If so, then
dy = funl2([],y,k1,k2,k3,mu,d1,d2,r,K,k,alpha,gamma,n);
x = norm(dy) - 1e-3;
isterm = x >= 0 || y(2) + y(3) < 10;
dir = 0;
  댓글 수: 1
Rose
Rose 2011년 4월 21일
Why didn't you write
isterm=1;
To my understanding isterm=1 means to stop the code, isn't it?

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

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by