⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stable_direct_wrc.m

📁 一个用MATLAB编写的优化控制工具箱
💻 M
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 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 variablesclear% Define plant parameters:global a1 a2 a3 a4 a5 b tau beta0 beta1a1=-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 approximatorsglobal pu RR=9; % Number of rulespu=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 termglobal cc=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)];       endendglobal sigma%sigma=0.5;sigma=2;% Next, parameters to compute the nu signalglobal k1 k0 gammak1=20;k0=100;gamma=2;% Sliding mode termglobal WuWu=0.01;  % A guess% Define matrix for calculation of reference signalsglobal AmAm=0*eye(4);% Set adaptation gainsglobal etauetau=2;% Define simulation parameters:Tfinal=2; % Units are secondsTspan=[0 Tfinal];% Define initial conditions:y0=[.4 0 0];   % For the plantym0=[0 0 0 0];  % For reference inputthetau0=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 signalsthetau=z(:,length(y0)+length(ym0)+1:length(y0)+length(ym0)+pu); % The parameters% Plot the plant signalsfigure(1)clfsubplot(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)clfplot(t,y(:,2),'k-',t,ym(:,2),'k--')title('Derivatives of y and y_m')xlabel('Time (sec)')figure(3)clfplot(t,thetau)title('\theta_u')xlabel('Time (sec)')%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% End of program%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -