Example: Modeling a Pitch Controller in Simulink

Physical setup and system equations
Building the State-Space Model
Open-loop response
Extracting the model into MATLAB
Building a full-state feedback controller
Closed-loop response

Physical setup and system equations

The equations governing the motion of an aircraft are a very complicated set of six non-linear coupled differential equations. However, under certain assumptions, they can be decoupled and linearized into the longitudinal and lateral equations. Pitch control is a longitudinal problem, and in this example, we will design an autopilot that controls the pitch of an aircraft. In this example, we will begin with the linearized state-space equation model which was obtained in the MATLAB Tutorials: pitch control example This model, with numerical values substituted in, is as follows:

in state-space form, the equations are as follows:
Which can be written as:

Building the state-space model

We will model these state equations explicitly in Simulink taking advantage of vector lines to carry the state vector signal X. Vector lines are produced automatically in Simulink when blocks input or output vector signals. First, we will represent the derivative of the state.

Now, we will represent the first state equation, which is d/dt(X)=Ax+Bu.

Now we will form the output signal which is equal to Cx+Du.

Next, we will apply inputs and extract outputs from this system. We will use In and Out blocks for this purpose. These blocks allow the system to be extracted into MATLAB and they allow the system to be placed into a Subsystem block for use within another model.

Save this model as "pitch.mdl" (or download ours here.)

Open-loop response

To generate the open-loop response, it is first necessary to contain this model in a subsystem block.

Before obtaining a step response, we must set the constants in the matrices A, B, C, and D. Enter the following commands at the MATLAB prompt.

We are now ready to run the simulation. If you like, you can download our version of the open-loop system here. Start the simulation by selecting Start from the Simulation menu (or hit Ctrl-t). When the simulation is finished, open the Scope by double clicking on it and hit the Scope's autoscale button. You will see the following response.

Extracting the model into MATLAB

The Simulink model can be extracted into an equivalent state-space model in MATLAB. This is done through the use of In and Out Connection blocks and the MATLAB function linmod.

To extract a model, it is necessary to start with a model file with inputs and outputs defined as In and Out blocks. Earlier in this tutorial this was done, and the file was saved as pitch.mdl. In this model, one input, deltac (the elevator angle) and two outputs, theta (pitch angle) and X (the state vector), were defined. We must truncate the output and feedthrough matrices (Co and Do) to provide only the first input.

At the MATLAB prompt, enter the following commands

You will see the following output providing the open-loop model of the system. Note that the matrices Ao, Bo, Co, and Do are the same at the original matrices A, B,C, and D.

Building a full-state feedback controller

In the CTMS Example: Pitch Controller -- State Space Method page, a full-state feedback controller was designed using the LQR method. We will now construct this controller in Simulink.

You can download our version of the closed-loop model here.

Closed-loop response

Before simulating the closed-loop system, we must first determine the gain matrix K using the LQR method. Execute the following commands at the MATLAB prompt. Start the simulation in Simulink. Open the scope window and hit the Autoscale button. You should see the following response.


Simulink Examples
Cruise Control | Motor Speed | Motor Position | Bus Suspension | Inverted Pendulum | Pitch Controller | Ball and Beam

Pitch Controller Examples
Modeling | PID | Root Locus | Frequency Response | State Space | Digital Control | Simulink

Tutorials
MATLAB Basics | MATLAB Modeling | PID | Root Locus | Frequency Response | State Space | Digital Control | Simulink Basics | Simulink Modeling | Examples