non-zero threshold for event function
2 views (last 30 days)
Show older comments
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.
0 Comments
Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!