classdef SwitchBetweenStableFlower < HybridSystem % Define the switched system as a subclass of HybridSystem. properties % Define variable class properties. ... end properties(SetAccess = immutable) % Define constant (i.e., "immutable") class properties. epsilon = 0.1; omega = 1; alpha = 5; end methods % Define functions, including definitions of f, g, C, and D. function xdot = flowMap(this, x, ~, ~) y = x(1:2); q = x(3); epsilon = this.epsilon; alpha = this.alpha; omega = this.omega; A1 = [-epsilon, omega; -alpha*omega, -epsilon]; A3 = A1; A2 = [-epsilon, alpha*omega; -omega, -epsilon]; A4 = A2; if q == 0 || q == 2 ydot = A1*y; elseif q == 1 || q == 3 ydot = A2*y; end xdot = [ydot; 0]; end function xplus = jumpMap(this, x) q = x(3); qplus = mod(q+1,4); xplus = [x(1:2); qplus]; end function inC = flowSetIndicator(~, x) q = x(3); inC = ((q==0 || q==2) && (abs(x(2))>=abs(x(1)))) || ((q==1 || q ==3) && (abs(x(2))<=abs(x(1)))); end function inD = jumpSetIndicator(~, x) q = x(3); inD = ((q==0 || q==2) && (abs(x(2))<=abs(x(1)))) || ((q==1 || q ==3) && (abs(x(2))>=abs(x(1)))); end end end