How to calculate roll, pitch and yaw?

You defined y = [1, 0, 0], then you asked for a rotation of 30 deg about this vector that is aligned with the X-axis.

Let’s say you want to represent the body attitude with respect to NED using the following angles:

  • Roll: 15 deg.
  • Pitch: 30 deg.
  • Yaw: 45 deg.

Then, angle_to_dcm(deg2rad(45), deg2rad(30), deg2rad(15), :ZYX) will provide that DCM that rotates NED to the body reference frame using the yaw-pitch-roll rotation sequence.