5. Simulation in MATLAB
5. Simulation in MATLAB
1. Consider the following flight control system and define aircraft and its parameters in
MATLAB.
𝛽𝛽̇
⎡ ⎤ −0.1245 0.0350 0.0414 −0.9962 ⎡ 𝛽𝛽 (deg) ⎤
⎢ 𝑝𝑝̇ ⎥ = �−15.2138 −2.0587 0.0032 0.6458 ⎢ 𝑝𝑝 (deg/s) ⎥
�
⎢𝜙𝜙̇⎥ 0 1 0 0 ⎢𝜙𝜙 (deg)⎥
⎣ 𝑟𝑟̇ ⎦ 1.6447 −0.0447 −0.0022 −0.1416 ⎣ 𝑟𝑟 (deg/s) ⎦
−0.0049 0.0237
−4.0379 0.9613 𝛿𝛿𝐴𝐴
+� �� �
0 0 𝛿𝛿𝑅𝑅
−0.0568 −1.2168
Φ p
p
ψref ψerr Φref Φerr pref
perr δA
Kψ KΦ KP Φ
ψ
sys TF
βref βerr rref rerr δR β
Kβ Kr
r
β r
Page 1 of 3
Flight Dynamics & Controls Center
Department of Aeronautics & Astronautics
Institute of Space Technology, Islamabad
sys = ss(A,B,eye(4),zeros(4,2));
sys.u = {'delta_A','delta_R'}; sys.y = {'beta','p','phi','r'};
TF = tf([g],[V 0]); TF.u = 'phi'; TF.y = 'psi';
Kp = tf(-10); Kp.u = 'p_err'; Kp.y = 'delta_A';
Kphi = tf(0.5); Kphi.u = 'phi_err'; Kphi.y = 'p_ref';
Kpsi = tf(5); Kpsi.u = 'psi_err'; Kpsi.y = 'phi_ref';
Kr = tf(-1); Kr.u = 'r_err'; Kr.y = 'delta_R';
Kbeta = tf(0.5); Kbeta.u = 'beta_err'; Kbeta.y = 'r_ref';
4. Define inputs and outputs of complete systems and connect the blocks.
Y = {'beta','p','phi','psi','r'};
U = {'psi_ref','beta_ref'};
T = connect(sys,TF,Kp,Kphi,Kpsi,Kr,Kbeta,sum1,sum2,sum3,sum4,sum5,U,Y);
Page 2 of 3
Flight Dynamics & Controls Center
Department of Aeronautics & Astronautics
Institute of Space Technology, Islamabad
%% Simulate
[y,t] = lsim(T,input,t); % Simulate the system
plot(t,y(:,[2,3,4])); % Plot 'p', 'phi' and 'psi'
Info = lsiminfo(y,t,[0,0,0,1,0]); % find response characteristics
Settling Time
Maximum Value
Page 3 of 3