フィルターのクリア

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 Center および File ExchangeNumerical 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