Aerospace in the command window#
Every name on this page is typed at the command window (or passed to
ICoreBlocks --console "<line>") and answers what MATLAB's Aerospace Toolbox
answers for the same arguments — same frames, same units, same shapes. Attitude
code, atmosphere lookups and geodetic conversions written for MATLAB should
paste in and run.
Angles are RADIANS and quaternions are N x 4 ROWS, because that is what
the toolbox uses. The one exception is geodesy, where MATLAB works in degrees
and so does this. Both conventions are stated per family below, because
mixing them is the single most expensive mistake on this page.
This console also has its own, older quaternion family on a 4 x 1 COLUMN —
quatmul, quatslerp, rotatevector, quatfromeuler, quat2euler,
quatfromaxisangle, quat2rotm, rotm2quat. Those are not MATLAB's names or
MATLAB's shape and they are marked as the console's own in
Command glossary — console commands, verbs, functions. Nothing on this page's promise rests on them, and
handing a row to one of them is refused with a message that names the MATLAB
family instead:
>>> rotatevector([0.7071, 0.7071, 0, 0], [0, 1, 0])
error: rotatevector(q, v): this console's quaternion is a 4 x 1 COLUMN and its vectors are 3 x 1 columns (T7.1) -- a ROW is MATLAB's shape, and quatmultiply, quatnormalize, quatconj, quatinv, quatrotate, quat2dcm and quat2angle are the console's names for that N x 4 row family. Transpose it, or use those
They do export to MATLAB, though — the column convention is not a dead end.
Seven of the eight translate, each into the MATLAB call it really is, and
toMatlab writes a small adapter beside the script that does the transposing:
Console (4 x 1 column) | The MATLAB call it becomes |
|---|---|
quatmul(p, q) | quatmultiply(p, q) on rows |
quatslerp(p, q, f) | quatinterp(p, q, f, "slerp") — the mode is named, not defaulted |
rotatevector(q, v) | quatrotate(quatconj(q), v) — the conjugate, because quatrotate turns the frame |
quat2rotm(q) | quat2dcm(q) transposed |
rotm2quat(R) | dcm2quat(R') — the input transpose, and dropping it negates the vector part |
quatfromeuler(yaw, pitch, roll) | angle2quat(yaw, pitch, roll, "ZYX") |
quat2euler(q) | quat2angle(q, "ZYX"), its three outputs stacked |
The eighth, quatfromaxisangle, has no MATLAB counterpart at all: Aerospace
ships no axis-angle constructor, and the spelling that does — axang2quat —
belongs to the Robotics System Toolbox, which is outside this console's eight.
⚠ quat2euler and quat2angle part company at gimbal lock, and neither is
wrong. At a pitch of pi/2 yaw and roll are no longer separable, and the two
implementations spend the free angle differently — this console answers
[pi; pi/2; pi] where MATLAB answers [0; pi/2; 0] for the same rotation.
Anywhere else the two agree to the last bits. If your code reads the yaw back
out near straight up, read it from the rotation matrix instead.
The families, and what to reach for#
| You want to | Use |
|---|---|
| Quaternion arithmetic | quatmultiply, quatdivide, quatconj, quatinv, quatnormalize, quatnorm, quatmod |
| Rotate with a quaternion | quatrotate (rotates the FRAME) |
| Interpolate an attitude | quatinterp(p, q, f, "slerp" | "lerp" | "nlerp"), quatlog, quatexp, quatpower |
| Convert between attitude forms | quat2dcm, dcm2quat, angle2quat, quat2angle, angle2dcm, dcm2angle, rod2quat, quat2rod, rod2dcm, dcm2rod, rod2angle, angle2rod — all twelve rotation orders |
| Build a frame DCM | dcmbody2wind, dcmbody2stability, dcmecef2ned, dcm2alphabeta, dcm2latlon |
| Look up the atmosphere | atmosisa, atmoscoesa, atmoslapse, atmospalt |
| Convert coordinates | lla2ecef, ecef2lla, lla2flat, flat2lla, geoc2geod, geod2geoc, geocradius |
| Get gravity | gravitywgs84, gravitycentrifugal, gravityzonal |
| Measure a flight condition | machnumber, dpressure, airspeed, correctairspeed, alphabeta |
| Convert units | convvel, convlength, convang, convangvel, convangacc, convacc, convmass, convforce, convpres, convtemp, convdensity |
| Work with dates | juliandate, mjuliandate, decyear, leapyear, siderealTime |
A worked line or two#
The standard atmosphere at the tropopause, all four outputs:
>>> [T, a, P, rho] = atmosisa(11000)
T = 216.65 # Double
a = 295.069 # Double
P = 22632 # Double
rho = 0.363918 # Double
Quaternion arithmetic on MATLAB's rows, and the two "norms":
>>> quatmultiply([1, 2, 3, 4], [5, 6, 7, 8])
[[-60, 12, 30, 24]] # Matrix of Double
>>> [quatnorm([1 2 3 4]), quatmod([1 2 3 4])]
[[30, 5.47723]] # Matrix of Double
An attitude built from Euler angles, converted to a direction cosine matrix, and interpolated halfway to another:
>>> angle2quat(0.1, 0.2, 0.3)
[[0.983347, 0.143572, 0.106021, 0.0342708]] # Matrix of Double
>>> quat2dcm([1, 1, 0, 0])
[[1, 0, 0], [0, 2.23711e-17, 1], [0, -1, 2.23711e-17]] # Matrix of Double
>>> quatinterp([1 0 0 0], [0 1 0 0], 0.5, "slerp")
[[0.707107, 0.707107, 0, 0]] # Matrix of Double
Geodesy in degrees, gravity, and the calendar:
>>> lla2ecef([45, 9, 1000])
[[4.46267e+06, 706818, 4.48806e+06]] # Matrix of Double
>>> gravitywgs84(0, 45)
9.8062 # Double
>>> leapyear([1900, 2000, 2024])
[[0, 1, 1]] # Matrix of Logical
Every transcript on this page is real output, captured with
ICoreBlocks --console "<line>" on 2026-09-05 at commit bd974745.
Eight things that surprise people#
These are MATLAB's behaviours, reproduced on purpose. Each one has a measured reason, and each has cost somebody an afternoon.
quatnormis the SQUARED modulus.quatnorm([1 2 3 4])is 30, notsqrt(30). The root isquatmod. The name that reads like a norm is the one that is not one — andquatinvdivides byquatnormwhilequatnormalizedivides byquatmod, which is the whole difference between those two names.quatdivide(q, r)isinv(r) * q— a LEFT division. The name invitesq * inv(r)and the documentation's "divides q by r" does not rule it out. Measured over 500 random pairs,quatdivide(q, r)equalsquatmultiply(quatinv(r), q)to the BIT and differs from the other reading by up to 12.5. On[1 2 3 4] / [5 6 7 8]the two readings are the same four numbers in a different order, which is the kind of wrong answer that looks right:``
>>> quatdivide([1 2 3 4], [5 6 7 8]) [[0.402299, 0, 0.091954, 0.045977]] # Matrix of Double``quatmultiply(q)with ONE argument is q * q. Not the identity, and not a normalisation.quatmultiply([1 2 3 4])is[-28 4 6 8]on both sides.quatrotaterotates the FRAME, not the vector.quatrotate(q, v)isq* v q—quat2dcm(q) * v. If you want to turn the vector and leave the frame still, that isquatrotate(quatconj(q), v). Both read as "rotate v by q" in prose, which is why the two get swapped.atmoscoesais notatmosisaunder another name, and they disagree in the sixth digit on purpose.atmoscoesaDERIVES its base pressures by walking the layer table whereatmosisa's are literals, and its gas constant is computed differently.atmospaltinvertsatmoscoesa's pressures, so round-tripping a height throughatmosisaand back lands about a millimetre away.- A ZERO Rodrigues vector answers four zeros, not the identity
quaternion.
rod2quat([0 0 0])is[0 0 0 0], because MATLAB'srod2quat.mallocates zeros and fills only the rows whose vector has a norm. Reproduced rather than corrected. decyearis not a Julian date rescaled. Its divisor is the length of THAT year, so 1 July is .4959 of 2005 and .4973 of 2004.quat2dcmanswers the TRANSPOSE of the rotation matrixquat2rotmgives, and it normalises a non-unit quaternion first — which is whyquat2dcm([1 1 0 0])has 2.2e-17 where an exact 90-degree rotation would have 0, on both sides.quat2rotmis a Robotics System Toolbox spelling and is one of this console's own extras, not this name.
What is not here#
Refused, with the reason in the message:
atmosnonstd— the non-standard-day atmosphere.tdbjuliandate— the barycentric dynamical time scale.- The console's own column-vector quaternion names when handed a MATLAB row, and MATLAB's row names when handed a column: each refusal names the other family, as shown at the top of this page.
Not known to the console at all — typing one of these answers
unknown function '<name>':
| If you reach for | Use |
|---|---|
atmosnrlmsise00, atmoshwm, atmoscira | atmosisa or atmoscoesa. Those three are table-driven models whose data packages do not ship here |
wrldmagm, igrfmagm | nothing — the magnetic field models are data packages too |
geoidheight, gravitysphericalharmonic | gravitywgs84 or gravityzonal, which are closed forms |
dcmeci2ecef, planetEphemeris, moonLibration, earthNutation | siderealTime for Earth rotation; the ephemerides are data packages |
Aero.Animation, Aero.FixedWing, flight instruments | nothing — this console has no object types |
siderealTime is here and is worth one caution: MATLAB's polynomial ships
compiled, so what this console reproduces is Vallado's formula with MATLAB's
own rounded epoch constant. Agreement is 1e-13 at J2000 and better than 1e-9
within ±50 years of it. Outside that window it drifts, slowly and predictably.
Where to look next#
- Command glossary — console commands, verbs, functions — every name the console answers, grouped by toolbox, with each one's arguments; the console's own quaternion spellings are marked there as extras.
- The command window — the command engine for a user — the engine itself: variables, multiple outputs, scripts, and running a line headlessly.
- Numerics — what the solver will and will not do — what a double can carry, and where these answers stop being exact.