Borrar filtros
Borrar filtros

odeevent

3 visualizaciones (últimos 30 días)
Rose
Rose el 20 de Abr. de 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!!

Respuestas (1)

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

Iniciar sesión para comentar.

Categorías

Más información sobre Numerical Integration and Differential Equations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by