non-zero threshold for event function

1 次查看(过去 30 天)
9times6
9times6 2019-9-10
编辑: 9times6 2019-9-10
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 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

产品


版本

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by