1function eulerangles = rot2euler(R)
 2%#codegen
 3
 4phi   = atan2(R(3,2),R(3,3));
 5theta = -asin(R(3,1));
 6psi   = atan2(R(2,1),R(1,1));
 7
 8eulerangles = [phi;theta;psi];
 9
10end