Clear Filters
Clear Filters

non-zero threshold for event function

1 view (last 30 days)
9times6
9times6 on 10 Sep 2019
Edited: 9times6 on 10 Sep 2019
I have written the following event function. Since, I have to detect a non-zero event, I have used Boolean operator as shown.
function [value,isterminal,direction] = myevent12d1(t,y)
% Locate the time when height passes through zero in a decreasing direction
% and stop integration.
z=y(1)<y(3)
value = z; % detect height = 0
isterminal = 1; % stop the integration
direction = -1; % negative direction
However, when I run my code, I recieve the following error
Undefined function 'sign' for input arguments of type 'logical'.
Error in odezero (line 46)
indzc = find((sign(vL) ~= sign(vR)) & (direction .* (vR - vL) >= 0));
Error in ode45 (line 352)
[te,ye,ie,valt,stop] = ...
Error in onedof2dof (line 19)
[t1,y1,te1,ye1,ie1]=ode45(@(t,y) sp121(t,y,k1,k2,m1,m2),[tstart tfinal],y0,options1);
options1 is defined as:
options1 = odeset('Events',@myevent12d1);
Please help me in this reagrd. Thanks.

Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2015a

Community Treasure Hunt

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

Start Hunting!