the Simulink model. This evaluates each gain surface formula at the breakpoints specified
in the two Prelookup blocks and writes the result in the corresponding Interpolation
block.
writeBlockValue(ST)
Now simulate the autopilot performance for a maneuver that takes the airframe through a
large portion of its flight envelope. The code below is equivalent to pressing the Play
button in the Simulink model and inspecting the responses in the Scope blocks.
% Initial conditions
h_ini = 1000;
alpha_ini = 0;
v_ini = 700;
% Simulate
SimOut = sim('rct_airframeGS', 'ReturnWorkspaceOutputs', 'on');
% Extract simulation data
SimData = get(SimOut,'sigsOut');
Sim_gamma = getElement(SimData,'gamma');
Sim_alpha = getElement(SimData,'alpha');
Sim_V = getElement(SimData,'V');
Sim_delta = getElement(SimData,'delta');
Sim_h = getElement(SimData,'h');
Sim_az = getElement(SimData,'az');
t = Sim_gamma.Values.Time;
% Plot the main flight variables
clf
subplot(211)
plot(t,Sim_gamma.Values.Data(:,1),'r--',t,Sim_gamma.Values.Data(:,2),'b'), grid
legend('Commanded','Actual','location','SouthEast')
title('Flight path angle \gamma in degrees')
subplot(212)
plot(t,Sim_delta.Values.Data), grid
title('Elevator deflection \delta in degrees')
Tuning of Gain-Scheduled Three-Loop Autopilot