File Exchange

image thumbnail

Draw a 3D airplane

version (1.2 MB) by Chad Greene
Draw a very simple 3D airplane and animate it too


Updated 04 Mar 2016

View License

The c130 function draws a simple 3D airplane modelled after the Lockheed C-130. The xyz2rpy function estimates roll, pitch, and yaw from given x,y,z coordinates. No special toolboxes required.

h = c130(...)


c130 draws a 3D airplane.

c130(x,y,z) draws an airplane centered approximately at the location given by x,y,z, where x, y, and z must be scalar values.

c130(...,'roll',RollDegrees) specifies roll of the aircraft in degrees relative to the approximate center of gravity of the aircraft.

c130(...,'pitch',PitchDegrees) specifies pitch of the aircraft in degrees.

c130(...,'yaw',YawDegrees) specifies yaw of the aircraft in degrees in the global coordinate system. The xyz2rpy function may help with determining appropriate yaw values.

c130(...,'color',AirplaneColor) specifies a color of all surfaces of the plane. Color may be given by Matlab color name (e.g., 'red'), Matlab color abbreviation (e.g., 'r'), or RGB value (e.g., [1 0 0]). The 'color' option may be paired with options for specifying colors of specific parts of the plane. For example, c130('color','b','wing',y) creates a blue airplane with yellow wings. Default color is gray.

c130(...,'fuselage',FuselageColor) specifies fuselage color.

c130(...,'wing',WingColor) specifies wing color.

c130(...,'tailwing',TailwingColor) specifies color of horizontal stabilizer wings at the tail of the plane.

c130(...,'fin',FinColor) specifies color of the vertical stabilizer fin at the tail of the plane.

c130(...,'prop',PropellerColor) specifies propeller color.

c130(...,'scale',SizeScaleFactor) scales dimensions of the plane by some scalar factor. By default, c130 draws an airplane with dimensions which approximately match the dimensions C-130 airplane in meters. If you'd like to draw a C-130 in dimensions of feet, try c130('scale',3.281).

c130(...,'z',ZScaleFactor) scales only vertical dimensions by some scalar value. This may be useful if you're animating an airplane in a coordinate system where the vertical dimension is stretched to show relief. If your axes are not equal, consider a ZScaleFactor given by the ratio of (xlim(2)-xlim(1))/(zlim(2)-zlim(1)).

c130(...,'linestyle','LineStyle') specifies style of the lines connecting surface vertices. Default is '-', but can be set to any valid linestyle, including 'none' to show a smooth surface.

c130(...,'linecolor',LineColor) specifies edge color of lines connecting surface verticies. Default line color is black.

h = c130(...) returns handles of the 13 surface objects created by c130.

Cite As

Chad Greene (2020). Draw a 3D airplane (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (18)

Aircraft isn't rotated about it's own (0,0,0) reference point. This means that when roll/pitch/yaw values are nonzero, the aircraft origin no longer lies on the specified x, y, and z input location.

Ainee Rafi

wow that's amazing



Nice one!

Very good job! May I know how to simultaneously run this with different sets of data for roll, pitch, and yaw? I want to visualize my data so I want to see like an animation of it. Thanks!

Nice job. Waiting you to make a same program for ships. :D



muchas gracias



Super job

Hector Wan

I just tried to run the file, it give me error
Error: File: drawairplane.m Line: 16 Column: 3
The expression to the left of the equals sign is not a valid target for an assignment.

with which name should I SAVE the file?

E. Cheynet

Great job, dude.

Ned Gulley

Ligong Han

Based on a Lockheed C-130, but much cuter.


MathWorks update: Added Live Script.

MATLAB Release Compatibility
Created with R2016a
Compatible with any release
Platform Compatibility
Windows macOS Linux