The examples above will have the same effect.
While a quaternion represents only an orientation (or “rotation”) in space, a matrix can represent orientation as well as position, and scale. When dealing with position, rotation, and scale all together, it is often convenient to represent them as a single matrix.