non-zero threshold for event function
Mostrar comentarios más antiguos
I have written the following event function and I want to detect an event which is non-zero. Therefore, I am using the logical operator since event function will only work for value=0. In this code, y is 4x1 vector.
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
However, upon running the code, I am getting the following error message:
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);
Any help in this regard would be appreciated.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Ordinary Differential Equations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!