function xdot = stick_b2(t,x)
x1p_rad=45*pi/180;
m=2;
a=.1;
l=.5;
g=9.8;
disturb=m*l*(x(2))^2*sin(x(1));
B1=[0 -a/(4*l/3-a*m*l) 0 (4*a/3)/(4/3-m*a)]';
B2=[0 -a*cos(x1p_rad)/(4*l/3-a*m*l*(cos(x1p_rad))^2) ...
0 (4*a/3)/(4/3-m*a*(cos(x1p_rad))^2)]';
mu1=(1-1/(1+exp(-14*(x(1)-pi/8))))*(1/(1+exp(-14*(x(1)+pi/8))));
mu2=1-mu1;
F1 =[-294.8766  -73.1208  -13.4726  -27.3362];
F2 =[-440.3915 -118.5144  -19.1611  -35.5575];
u1=-(mu1*F1+mu2*F2)*x;
eta=abs(m*l*(x(2))^2*sin(x(1)));
Ps=[54.9580   15.6219    6.9389   12.1165
    15.6219    4.5429    2.1011    3.5488
     6.9389    2.1011    1.3972    1.7978
    12.1165    3.5488    1.7978    2.9375];
mu=(mu1*B1+mu2*B2)'*Ps*x;
%u2=-eta*(1/2)*(abs((1/.25)*mu+1)-abs((1/.25)*mu-1));
u2=-eta*sign(mu);
u=u1+u2;
Fm=[x(2) g*sin(x(1))/(4*l/3-m*l*a*(cos(x(1)))^2) x(4) ...
-(m*a*g*sin(2*x(1))/2)/(4/3-m*a*(cos(x(1)))^2)]';
Gm=[0 -(a*cos(x(1)))/(4*l/3-m*l*a*(cos(x(1)))^2) ...
0 (4*a/3)/(4/3-m*a*(cos(x(1)))^2)]';
xdot=Fm+Gm*(u+disturb);
