classdef SwitchBetweenUnstable < 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. A1 = [1, -100; 10, 1]; A2 = [1, 10; -100, 1]; end methods % Define functions, including definitions of f, g, C, and D. function xdot = flowMap(this, x, ~, ~) q = x(3); y = x(1:2); A1 = this.A1; A2 = this.A2; if q == 1 ydot = A1*y; elseif q == 2 ydot = A2*y; end xdot = [ydot; 0]; end function xplus = jumpMap(this, x) q = x(3); qplus = 3-q; xplus = [x(1:2); qplus]; end function inC = flowSetIndicator(~, x) q = x(3); inC = (q==1 && x(2)>=-x(1)) || (q==2 && x(2)>=0); end function inD = jumpSetIndicator(~, x) q = x(3); inD = (q==1 && x(2)<=-x(1)) || (q==2 && x(2)<=0); end end end