non-zero threshold for event function
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!