No BSD License  

Highlights from
Event-based Friction Hardstop Demo

image thumbnail
from Event-based Friction Hardstop Demo by Martin Murillo
Plain MATLAB version of the Simulink demo HARDSTOP.MDL.

hard_stop(t,y)
% This function is called through the hard_main file.  It is part
% of the 'odeset' directive and it sets the conditions upon which
% hard_func.m will stop integration (events)
% g determines the stopping function, isterminal determines whether the
% main function will stop or continue upon an event and direction specifies
% which direction to consider for the triggering of an event.
function [g,isterminal,direction] = hard_stop(t,y)
   % If g(1)=f(1)-5.5 or g(2)=f(1)+3.5 or g(3)=f(2) stop!
   % i.e. stops if block (displacement) hits thresholds.    
   % Will restart with v=0
   g = [y(1)-5.5; y(1)+3.5; y(2)];
   
   % All those imply to stop the current integration
   isterminal = [1; 1; 1];
   
   % Stops when position reaches +5.5 (from bottom), 
   % reaches -3.5 (from top) 
   % or when v passes zero  (from anywhre)
   direction = [1; -1; 0];

Contact us at files@mathworks.com