# Get Started with Fixed-Wing Aircraft

This example shows how to create and use fixed-wing aircraft in MATLAB®.

For an example of setting realistic coefficients on an aircraft and calculating static stability, see "Determine Nonlinear Dynamics and Static Stability of Fixed-Wing Aircraft”.

For an example of importing coefficients from Digital DATCOM analysis and linearizing to a state-space model, see “Analyze State-Space Model for Linear Control and Static Stability Analysis”.

For an example of creating custom states, see “Customize Fixed-Wing Aircraft with Additional Aircraft States”.

### What Is a Fixed-Wing Aircraft?

Fixed-wing aircraft encompass all aircraft that generate lift from fixed airfoil surfaces extending off the main body. The standard configuration for fixed-wing aircraft is a large main wing near the center of gravity and horizontal and vertical stabilizers at the end of the body.

The large main wing of the fixed-wing aircraft generates lift, with the horizontal and vertical stabilizers providing reaction forces and moments for stability and control. However, unlike rotary-wing aircraft, the fixed-wing aircraft's wings are fixed in place. Therefore, to provide the airflow to generate the necessary lift to fly aircraft off the ground, the fixed-wing aircraft wings require forward movement. This forward movement is typically created from a thrust vector generated by a jet engine or propeller.

### Fixed-Wing Aircraft Construction Workflow

The construction of a fixed-wing aircraft model requires these components:

The configuration of the aircraft

What aerodynamic surfaces exist on the aircraft?

What control surfaces exist on the aircraft?

What thrust vectors exist on the aircraft?

The numerical model of the aircraft

The current state of the aircraft

This example follows this workflow to illustrate how to construct a fixed-wing aircraft application for numerical analysis in MATLAB.

### Fixed-Wing Aircraft Configuration

This example constructs a basic 3-control surface, standard-configuration aircraft.

For this example, only the control surfaces and body will be defined.

To start, define the control surfaces using the fixedWingSurface function.

`surface = fixedWingSurface("mysurface")`

surface = Surface with properties: Surfaces: [1x0 Aero.FixedWing.Surface] Coefficients: [1x1 Aero.FixedWing.Coefficient] MaximumValue: Inf MinimumValue: -Inf Controllable: off Symmetry: "Symmetric" ControlVariables: [0x0 string] Properties: [1x1 Aero.Aircraft.Properties]

The surface has many properties that help define a fixed-wing aircraft surface, in particular the controllability, coefficients, maximum and minimum values. symmetry, and any nested surfaces a surface might have.

For this aircraft, the aileron is an asymmetric control surface with a maximum and minimum deflection of 20 and -20 degrees, respectively.

To construct this surface, name-value pairs can be specified to set each property to their desired level.

aileron = fixedWingSurface("aileron", "on", "Asymmetric", [-20, 20])

aileron = Surface with properties: Surfaces: [1x0 Aero.FixedWing.Surface] Coefficients: [1x1 Aero.FixedWing.Coefficient] MaximumValue: 20 MinimumValue: -20 Controllable: on Symmetry: "Asymmetric" ControlVariables: ["aileron_1" "aileron_2"] Properties: [1x1 Aero.Aircraft.Properties]

Using the same pattern as the aileron construct the elevators and rudders.

These two surfaces follow the same pattern as the aileron, but are defined as symmetric control surfaces.

elevator = fixedWingSurface("elevator", "on", "Symmetric", [-20, 20])

elevator = Surface with properties: Surfaces: [1x0 Aero.FixedWing.Surface] Coefficients: [1x1 Aero.FixedWing.Coefficient] MaximumValue: 20 MinimumValue: -20 Controllable: on Symmetry: "Symmetric" ControlVariables: "elevator" Properties: [1x1 Aero.Aircraft.Properties]

rudder = fixedWingSurface("rudder", "on", "Symmetric", [-20, 20])

rudder = Surface with properties: Surfaces: [1x0 Aero.FixedWing.Surface] Coefficients: [1x1 Aero.FixedWing.Coefficient] MaximumValue: 20 MinimumValue: -20 Controllable: on Symmetry: "Symmetric" ControlVariables: "rudder" Properties: [1x1 Aero.Aircraft.Properties]

In addition to the control surfaces of the aircraft, also define the thrust vectors.

For this example, it is assumed that there is a single thrust vector along the body of the aircraft.

Define this thrust vector using the fixedWingThrust function.

propeller = fixedWingThrust("propeller","on","Symmetric",[0, 0.75])

propeller = Thrust with properties: Coefficients: [1x1 Aero.FixedWing.Coefficient] MaximumValue: 0.7500 MinimumValue: 0 Controllable: on Symmetry: "Symmetric" ControlVariables: "propeller" Properties: [1x1 Aero.Aircraft.Properties]

Thrust is nearly identical to surface with the exception that it is assumed to be controllable by default, whereas the surface is not controllable by default.

With these control surfaces and thrust vectors defined, create an aircraft using the fixedWingAircraft function.

This aircraft carries the full definition of the fixed-wing aircraft. This example uses it in all analysis methods.

The reference area, span, and length help dimensionalize non-dimensional coefficients used in the analysis methods.

For simplicity, this aircraft uses a reference area, span, and length of 3, 2, and 1, respectively.

`aircraft = fixedWingAircraft("MyAircraft", 3,2,1)`

aircraft = FixedWing with properties: ReferenceArea: 3 ReferenceSpan: 2 ReferenceLength: 1 Coefficients: [1x1 Aero.FixedWing.Coefficient] DegreesOfFreedom: "6DOF" Surfaces: [1x0 Aero.FixedWing.Surface] Thrusts: [1x0 Aero.FixedWing.Thrust] AspectRatio: 1.3333 Properties: [1x1 Aero.Aircraft.Properties] UnitSystem: "Metric" TemperatureSystem: "Kelvin" AngleSystem: "Radians"

Additionally, the control surfaces and thrust vectors can be applied to the aircraft

aircraft.Surfaces = [aileron, elevator, rudder]

aircraft = FixedWing with properties: ReferenceArea: 3 ReferenceSpan: 2 ReferenceLength: 1 Coefficients: [1x1 Aero.FixedWing.Coefficient] DegreesOfFreedom: "6DOF" Surfaces: [1x3 Aero.FixedWing.Surface] Thrusts: [1x0 Aero.FixedWing.Thrust] AspectRatio: 1.3333 Properties: [1x1 Aero.Aircraft.Properties] UnitSystem: "Metric" TemperatureSystem: "Kelvin" AngleSystem: "Radians"

aircraft.Thrusts = propeller

aircraft = FixedWing with properties: ReferenceArea: 3 ReferenceSpan: 2 ReferenceLength: 1 Coefficients: [1x1 Aero.FixedWing.Coefficient] DegreesOfFreedom: "6DOF" Surfaces: [1x3 Aero.FixedWing.Surface] Thrusts: [1x1 Aero.FixedWing.Thrust] AspectRatio: 1.3333 Properties: [1x1 Aero.Aircraft.Properties] UnitSystem: "Metric" TemperatureSystem: "Kelvin" AngleSystem: "Radians"

With the aircraft body construct and control surfaces set, the aircraft is now fully constructed.

However, the current construction of the aircraft does not have much numerical meaning as the numerical model has defaults of 0.

To remedy this, set numeric coefficients.

### Fixed-Wing Aircraft Numerical Modeling

To perform numerical modeling using fixed-wing aircraft in MATLAB, define known coefficients that represent the nonlinear behavior of the aircraft at its various operating states. Aircraft coefficients are the fixed set of coefficients that define body forces and moments, excluding reaction forces due to control surfaces or thrust vectors.

Obtain these coefficients through a variety of methods, such as Digital DATCOM, Computational Fluid Dynamics (CFD) analysis, or using first-principles preliminary analysis calculations.

If using Digital DATCOM to calculate the numeric coefficients, directly convert the Digital DATCOM struct to a fixed-wing aircraft using datcomToFixedWing.

You can also manually import assign the coefficients to the aircraft.

Fixed-wing aircraft coefficients reside on the aircraft in several places. As can be seen above, the aircraft itself, and every surface and thrust on the aircraft, has a set of coefficients.

Control surface coefficients define the forces and moments due to control surface deflections.

Thrust coefficients define the forces and moments due to the various propulsion methods.

All these independent forces and moments summed together provide the full forces and moments definition of the aircraft, and in turn the nonlinear dynamics.

Define coefficients using the fixedWingCoefficient function.

coeff = fixedWingCoefficient

coeff = Coefficient with properties: Table: [6x1 table] Values: {6x1 cell} StateVariables: "Zero" StateOutput: [6x1 string] ReferenceFrame: "Wind" MultiplyStateVariables: on NonDimensional: on Properties: [1x1 Aero.Aircraft.Properties]

The fixedWingCoefficient function defines coefficient-specific properties, including the reference frame, specifying dimensional or non-dimensional coefficients, and specifying the state variable multiply behavior.

Setting coefficient values can be done through the setCoefficient function.

Retrieving coefficient values can be done through the getCoefficient function.

To view the coefficients of a component in a table, use the Table property on the returned coefficient.

CL_alpha = 0.2; aircraft = setCoefficient(aircraft, "CL", "Alpha", CL_alpha)

aircraft = FixedWing with properties: ReferenceArea: 3 ReferenceSpan: 2 ReferenceLength: 1 Coefficients: [1x1 Aero.FixedWing.Coefficient] DegreesOfFreedom: "6DOF" Surfaces: [1x3 Aero.FixedWing.Surface] Thrusts: [1x1 Aero.FixedWing.Thrust] AspectRatio: 1.3333 Properties: [1x1 Aero.Aircraft.Properties] UnitSystem: "Metric" TemperatureSystem: "Kelvin" AngleSystem: "Radians"

getCoefficient(aircraft, "CL", "Alpha")

ans = 0.2000

aircraft.Coefficients.Table

`ans=`*6×9 table*
Zero U Alpha AlphaDot Q Beta BetaDot P R
____ _ _____ ________ _ ____ _______ _ _
CD 0 0 0 0 0 0 0 0 0
CY 0 0 0 0 0 0 0 0 0
CL 0 0 0.2 0 0 0 0 0 0
Cl 0 0 0 0 0 0 0 0 0
Cm 0 0 0 0 0 0 0 0 0
Cn 0 0 0 0 0 0 0 0 0

You can also set coefficients on the nested surfaces and thrust vectors using their component name.

The component name is the same name that was set on the aircraft, surface, and thrust.

CL_0_elevator = 0.15; aircraft = setCoefficient(aircraft, "CL", "Zero", CL_0_elevator, Component="elevator")

aircraft = FixedWing with properties: ReferenceArea: 3 ReferenceSpan: 2 ReferenceLength: 1 Coefficients: [1x1 Aero.FixedWing.Coefficient] DegreesOfFreedom: "6DOF" Surfaces: [1x3 Aero.FixedWing.Surface] Thrusts: [1x1 Aero.FixedWing.Thrust] AspectRatio: 1.3333 Properties: [1x1 Aero.Aircraft.Properties] UnitSystem: "Metric" TemperatureSystem: "Kelvin" AngleSystem: "Radians"

getCoefficient(aircraft, "CL", "Zero",Component="elevator")

ans = 0.1500

aircraft.Surfaces(2).Coefficients.Table

`ans=`*6×1 table*
Zero
____
CD 0
CY 0
CL 0.15
Cl 0
Cm 0
Cn 0

Set the specific coefficients using the setCoefficient function. Retrieve them using the getCoefficient function. These coefficients depend on:

The input fixed-wing object

The reference frame on the coefficient

The state variables defined on the coefficient

The second input to setCoefficient and getCoefficient is the state output. To determine valid state outputs, refer to see the reference frame on the coefficient.

For example, if the reference frame is "Body", the valid state outputs are:

"CX" - Coefficient of body X force

"CY" - Coefficient of body Y force

"CZ" - Coefficient of body Z force

"Cl" - Rolling moment coefficient

"Cm" - Pitching moment coefficient

"Cn" - Yawing moment coefficient

```
coeff.ReferenceFrame = "Body";
coeff.Table
```

`ans=`*6×1 table*
Zero
____
CX 0
CY 0
CZ 0
Cl 0
Cm 0
Cn 0

If the reference frame is "Wind", the valid state outputs are:

"CD" - Coefficient of drag force

"CY" - Coefficient of body Y force

"CL" - Coefficient of lift force

"Cl" - Rolling moment coefficient

"Cm" - Pitching moment coefficient

"Cn" - Yawing moment coefficient

```
coeff.ReferenceFrame = "Wind";
coeff.Table
```

`ans=`*6×1 table*
Zero
____
CD 0
CY 0
CL 0
Cl 0
Cm 0
Cn 0

The third input argument to setCoefficient and getCoefficient is the state variables that determine the states the coefficients are defined with.

By default, the coefficient assumes no state relationship. These coefficients are defined with the "Zero" state variable, which means the coefficient has no states to multiply against.

In the case of the fixed-wing aircraft, there are a set of additional default states that are common to many aircraft definitions, namely, U, Alpha, AlphaDot, Beta, BetaDot, P, Q, and R.

Use any combination of these state outputs and state variables with setCoefficient and getCoefficient.

coeff.StateVariables = ["Alpha", "Beta"]; coeff = setCoefficient(coeff, "CL", "Beta", 5); coeff.Table

`ans=`*6×2 table*
Alpha Beta
_____ ____
CD 0 0
CY 0 0
CL 0 5
Cl 0 0
Cm 0 0
Cn 0 0

With the coefficients set on the aircraft, define the aircraft current state.

### Fixed-Wing Aircraft States

The current state of an aircraft defines the properties that are independent of the fixed configuration.

These properties include the mass, inertia, airspeed, altitude, deflection angles, and others.

By separating the current state from the configuration, the aircraft coefficient data can remain fixed while individual states change over time.

Define fixed-wing aircraft states using the fixedWingState function.

state = fixedWingState(aircraft)

state = State with properties: Alpha: 0 Beta: 0 AlphaDot: 0 BetaDot: 0 Mass: 0 Inertia: [3x3 table] CenterOfGravity: [0 0 0] CenterOfPressure: [0 0 0] AltitudeMSL: 0 GroundHeight: 0 XN: 0 XE: 0 XD: 0 U: 50 V: 0 W: 0 Phi: 0 Theta: 0 Psi: 0 P: 0 Q: 0 R: 0 Weight: 0 AltitudeAGL: 0 Airspeed: 50 GroundSpeed: 50 MachNumber: 0.1469 BodyVelocity: [50 0 0] GroundVelocity: [50 0 0] Ur: 50 Vr: 0 Wr: 0 FlightPathAngle: 0 CourseAngle: 0 InertialToBodyMatrix: [3x3 double] BodyToInertialMatrix: [3x3 double] BodyToWindMatrix: [3x3 double] WindToBodyMatrix: [3x3 double] BodyToStabilityMatrix: [3x3 double] StabilityToBodyMatrix: [3x3 double] DynamicPressure: 1.5312e+03 Environment: [1x1 Aero.Aircraft.Environment] ControlStates: [1x6 Aero.Aircraft.ControlState] OutOfRangeAction: "Limit" DiagnosticAction: "Warning" Properties: [1x1 Aero.Aircraft.Properties] UnitSystem: "Metric" TemperatureSystem: "Kelvin" AngleSystem: "Radians"

The names of the properties on this state are the same as the state variable string names in the coefficients.

In the aircraft coefficient table above, each coefficient in the "Alpha" column is multiplied by the "Alpha" property in the state if "MultiplyStateVariables" is on.

This action applies for every state variable in every coefficient on the aircraft.

Some states are dependent states and depend on other properties within the state itself.

If a state depends on properties within the environment, you must define the current flying environment as well.

Define the current flying environment using the aircraftEnvironment function or by assigning to the environment directly on the state.

`environment = aircraftEnvironment(aircraft, "ISA", 0)`

environment = Environment with properties: WindVelocity: [0 0 0] Density: 1.2250 Temperature: 288.1500 Pressure: 101325 SpeedOfSound: 340.2941 Gravity: 9.8100 Properties: [1x1 Aero.Aircraft.Properties]

state.Environment = environment

state = State with properties: Alpha: 0 Beta: 0 AlphaDot: 0 BetaDot: 0 Mass: 0 Inertia: [3x3 table] CenterOfGravity: [0 0 0] CenterOfPressure: [0 0 0] AltitudeMSL: 0 GroundHeight: 0 XN: 0 XE: 0 XD: 0 U: 50 V: 0 W: 0 Phi: 0 Theta: 0 Psi: 0 P: 0 Q: 0 R: 0 Weight: 0 AltitudeAGL: 0 Airspeed: 50 GroundSpeed: 50 MachNumber: 0.1469 BodyVelocity: [50 0 0] GroundVelocity: [50 0 0] Ur: 50 Vr: 0 Wr: 0 FlightPathAngle: 0 CourseAngle: 0 InertialToBodyMatrix: [3x3 double] BodyToInertialMatrix: [3x3 double] BodyToWindMatrix: [3x3 double] WindToBodyMatrix: [3x3 double] BodyToStabilityMatrix: [3x3 double] StabilityToBodyMatrix: [3x3 double] DynamicPressure: 1.5312e+03 Environment: [1x1 Aero.Aircraft.Environment] ControlStates: [1x6 Aero.Aircraft.ControlState] OutOfRangeAction: "Limit" DiagnosticAction: "Warning" Properties: [1x1 Aero.Aircraft.Properties] UnitSystem: "Metric" TemperatureSystem: "Kelvin" AngleSystem: "Radians"

The environment is assumed to be the same unit system as the state. It is important to keep these unit systems aligned and to align the unit systems between each state and aircraft.

Creating an array of many states can be helpful for designing the sweep of parameters over which to perform calculations on the aircraft.

In this example, 11 states are created by varying mass, but holding airspeed constant.

mass = num2cell(1000:50:1500)

`mass=`*1×11 cell array*
{[1000]} {[1050]} {[1100]} {[1150]} {[1200]} {[1250]} {[1300]} {[1350]} {[1400]} {[1450]} {[1500]}

state = fixedWingState(aircraft, U=100)

state = State with properties: Alpha: 0 Beta: 0 AlphaDot: 0 BetaDot: 0 Mass: 0 Inertia: [3x3 table] CenterOfGravity: [0 0 0] CenterOfPressure: [0 0 0] AltitudeMSL: 0 GroundHeight: 0 XN: 0 XE: 0 XD: 0 U: 100 V: 0 W: 0 Phi: 0 Theta: 0 Psi: 0 P: 0 Q: 0 R: 0 Weight: 0 AltitudeAGL: 0 Airspeed: 100 GroundSpeed: 100 MachNumber: 0.2939 BodyVelocity: [100 0 0] GroundVelocity: [100 0 0] Ur: 100 Vr: 0 Wr: 0 FlightPathAngle: 0 CourseAngle: 0 InertialToBodyMatrix: [3x3 double] BodyToInertialMatrix: [3x3 double] BodyToWindMatrix: [3x3 double] WindToBodyMatrix: [3x3 double] BodyToStabilityMatrix: [3x3 double] StabilityToBodyMatrix: [3x3 double] DynamicPressure: 6125 Environment: [1x1 Aero.Aircraft.Environment] ControlStates: [1x6 Aero.Aircraft.ControlState] OutOfRangeAction: "Limit" DiagnosticAction: "Warning" Properties: [1x1 Aero.Aircraft.Properties] UnitSystem: "Metric" TemperatureSystem: "Kelvin" AngleSystem: "Radians"

states = repmat(state, size(mass))

`states=`*1×11 State array with properties:*
Alpha
Beta
AlphaDot
BetaDot
Mass
Inertia
CenterOfGravity
CenterOfPressure
AltitudeMSL
GroundHeight
XN
XE
XD
U
V
W
Phi
Theta
Psi
P
Q
R
Weight
AltitudeAGL
Airspeed
GroundSpeed
MachNumber
BodyVelocity
GroundVelocity
Ur
Vr
Wr
FlightPathAngle
CourseAngle
InertialToBodyMatrix
BodyToInertialMatrix
BodyToWindMatrix
WindToBodyMatrix
BodyToStabilityMatrix
StabilityToBodyMatrix
DynamicPressure
Environment
ControlStates
OutOfRangeAction
DiagnosticAction
Properties
UnitSystem
TemperatureSystem
AngleSystem

[states.Mass] = mass{:}

`states=`*1×11 State array with properties:*
Alpha
Beta
AlphaDot
BetaDot
Mass
Inertia
CenterOfGravity
CenterOfPressure
AltitudeMSL
GroundHeight
XN
XE
XD
U
V
W
Phi
Theta
Psi
P
Q
R
Weight
AltitudeAGL
Airspeed
GroundSpeed
MachNumber
BodyVelocity
GroundVelocity
Ur
Vr
Wr
FlightPathAngle
CourseAngle
InertialToBodyMatrix
BodyToInertialMatrix
BodyToWindMatrix
WindToBodyMatrix
BodyToStabilityMatrix
StabilityToBodyMatrix
DynamicPressure
Environment
ControlStates
OutOfRangeAction
DiagnosticAction
Properties
UnitSystem
TemperatureSystem
AngleSystem

The second environment input can also help create a state array that iterates over many altitudes using a standard atmosphere model.

`statesH = fixedWingState(aircraft, aircraftEnvironment(aircraft, "ISA", [0, 1000, 2000]))`

`statesH=`*1×3 State array with properties:*
Alpha
Beta
AlphaDot
BetaDot
Mass
Inertia
CenterOfGravity
CenterOfPressure
AltitudeMSL
GroundHeight
XN
XE
XD
U
V
W
Phi
Theta
Psi
P
Q
R
Weight
AltitudeAGL
Airspeed
GroundSpeed
MachNumber
BodyVelocity
GroundVelocity
Ur
Vr
Wr
FlightPathAngle
CourseAngle
InertialToBodyMatrix
BodyToInertialMatrix
BodyToWindMatrix
WindToBodyMatrix
BodyToStabilityMatrix
StabilityToBodyMatrix
DynamicPressure
Environment
ControlStates
OutOfRangeAction
DiagnosticAction
Properties
UnitSystem
TemperatureSystem
AngleSystem

### Fixed-Wing Analysis Methods

With the construction of the aircraft and its states, you can now perform fixed-wing specific calculations.

These calculations can include:

Forces and moments

Nonlinear dynamics

Static stability

Linearization to a state-space model

F = zeros(numel(states), 3); M = zeros(numel(states), 3); dydt = zeros(numel(states), 12); for i = 1:numel(states) [F(i,:), M(i,:)] = forcesAndMoments(aircraft, states(i)); dydt(i,:) = nonlinearDynamics(aircraft, states(i)); end

The aircraft can also be used as a generic container to hold the aircraft definition as it is passed around to other parts of the program, such as in a Simulink lookup table or custom MATLAB analysis functions.

In summary, the fixed-wing aircraft functions provide a common definition to creating and manipulating fixed-wing aircraft within MATLAB.

## See Also

`fixedWingAircraft`

| `fixedWingCoefficient`

| `fixedWingState`

| `fixedWingSurface`

| `aircraftEnvironment`

| `fixedWingThrust`