non-zero threshold for event function

1 visualizzazione (ultimi 30 giorni)
9times6
9times6 il 10 Set 2019
Modificato: 9times6 il 10 Set 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.

Risposte (0)

Categorie

Scopri di più su Programming in Help Center e File Exchange

Prodotti


Release

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by