function xdot=plant(t,x);
%This function file is used in the directid.m to identify forward dynamics
% of the Kapitsa pendulum
g=9.81;
l=0.7;
A_1=0.4;
A_2=2;
A_3=3;
nu=0.05;
k=50;
delta=0.05;
u=A_1+A_2*cos(t/(2*nu))+A_3*sin(t/nu);
A_tilde=[0 1 0 0;0 0 1 0;-1 -3 -3 0;0 0 0 0];
b_tilde=[0 0 1 0]';
y_ada=x(1:4)'*x(5:8);
e=y_ada-x(9);
% Below is eqn (54) and the equations modeling the Kapitsa pendulum
% from the Dec 1995 IEEE CAS paper of Sira-Ramirez and Colina-Morles.
% This eqn is an implementation of the continuous time adaptive adaline
% Notice that the input to the adaline is the same as the input to the pendulum
xdot=[A_tilde*x(1:4)+b_tilde*u;
      -(((x(1:4)*x(1:4)')/(x(1:4)'*x(1:4)))*A_tilde'+...
      u*((x(1:4)*b_tilde')/(x(1:4)'*x(1:4))))*x(5:8)-...
      (x(1:4)/(x(1:4)'*x(1:4)))*k*(e/(abs(e)+delta));
      x(10)+(u/l)*sin(x(9));(g/l-(u^2/l^2)*cos(x(9)))*sin(x(9))-(u/l)*x(10)*cos(x(9));u];
