%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % This program implements the stable direct controller % for the aircraft wing rock example (model/problem used % in the chapter, not in the homework problem). % % Kevin Passino % Version: 12/17/99 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Initialize variables clear % Define plant parameters: global a1 a2 a3 a4 a5 b tau beta0 beta1 a1=-0.0148927; a2=0.0415424; a3=0.01668756; a4=-0.06578382; a5=0.08578836; b=1.5; tau=1/15; beta0=10; beta1=40; % The number of parameters of the approximators global pu R R=9; % Number of rules pu=R*4; % For number of consequent parameters % Controller n=3; % Since in the plant we are computing y^(3) but really the state we % need is x=[x(1), x(2), x(3)]^T % We will use a TS fuzzy system but with only x(1) and x(2) as inputs % to the premise and all of x as an input to the consequent - with an affine term global c c=0*ones(n-1,1); % To force to be a column %gr=-1:0.5:1; gr=-2:2:2; [Cx,Cy]=meshgrid(gr,gr); l=0; for i=1:length(gr) for j=1:length(gr) l=l+1; c(:,l)=[Cx(i,j); Cy(i,j)]; end end global sigma %sigma=0.5; sigma=2; % Next, parameters to compute the nu signal global k1 k0 gamma k1=20; k0=100; gamma=2; % Sliding mode term global Wu Wu=0.01; % A guess % Define matrix for calculation of reference signals global Am Am=0*eye(4); % Set adaptation gains global etau etau=2; % Define simulation parameters: Tfinal=2; % Units are seconds Tspan=[0 Tfinal]; % Define initial conditions: y0=[.4 0 0]; % For the plant ym0=[0 0 0 0]; % For reference input thetau0=0.00*(-0.5*ones(1,pu)+rand(1,pu)); % Just pick small random values [t,z]=ode45('sdirwingrockc',Tspan,[y0 ym0 thetau0]); %[t,z]=ode15s('sdirwingrock',Tspan,[y0 ym0 thetau0]); y=z(:,1:3); % The plant states, and the y^(3) ym=z(:,4:7); % The reference model signals thetau=z(:,length(y0)+length(ym0)+1:length(y0)+length(ym0)+pu); % The parameters % Plot the plant signals figure(1) clf subplot(211) plot(t,y(:,1),'k-',t,ym(:,1),'k--') title('Roll angle y(t) (solid) and y_m(t) (dashed)') subplot(212) plot(t,y(:,3),'k-') xlabel('Time, sec.') ylabel('\delta_A') title('Aileron input') xlabel('Time (sec)') figure(2) clf plot(t,y(:,2),'k-',t,ym(:,2),'k--') title('Derivatives of y and y_m') xlabel('Time (sec)') figure(3) clf plot(t,thetau) title('\theta_u') xlabel('Time (sec)') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % End of program %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%