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?

  2 Comments

Walter Roberson
on 28 Jun 2013

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

Sarah Ghosh
on 28 Jun 2013

Yes, it comes with the options parameter of ode*

Products

No products are associated with this question.

1 Answer

Answer by Walter Roberson
on 28 Jun 2013
 Accepted answer

Return

 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.

  3 Comments

Sarah Ghosh
on 1 Jul 2013

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

Walter Roberson
on 1 Jul 2013

Return

double(y(1)-10 >= 1e-4)
Sarah Ghosh
on 1 Jul 2013

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


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today