MATLAB Answers

Sarah Ghosh

How to modify settings for event detection in MATLAB?

Asked by Sarah Ghosh
on 28 Jun 2013

I am writing a code for event detection. However, I want to increase the region of convergence from zero to about 1e-4.For example, instead of checking for y(1)-10=0, I want to check for y(1)-10<1e-4. How can this be done?


Are you referring to event detection in the context of one of the ode*() routines?

Yes, it comes with the options parameter of ode*


No products are associated with this question.

1 Answer

Answer by Walter Roberson
on 28 Jun 2013
 Accepted answer


 y(1)-10 >= 1e-4

This will be false (0) when it is within 1e-4. Set the options so the crossing direction does not matter.


Undefined function or method 'sign' for input arguments of type 'logical'. Error in ==> odezero at 47.

It looks like it does not accept a logical value


double(y(1)-10 >= 1e-4)

Yes, it worked.... thanks a lot for the help....

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!