Effacer les filtres
Effacer les filtres

odeevent

3 vues (au cours des 30 derniers jours)
Rose
Rose le 20 Avr 2011
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!!

Réponses (1)

Walter Roberson
Walter Roberson le 20 Avr 2011
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 commentaire
Rose
Rose le 21 Avr 2011
Why didn't you write
isterm=1;
To my understanding isterm=1 means to stop the code, isn't it?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Numerical Integration and Differential Equations dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by