[Math] How to verify that a matrix is a rotation matrix in Matlab

MATLABmatricesrotations

Using Matlab, I want to know if

$$A=\begin{pmatrix}
\cos(x) & \sin(x)\\ -\sin(x) & \cos(x)
\end{pmatrix}$$

is a rotation matrix. Hence,

$$\begin{pmatrix} \cos(x) & \sin(x)\\ -\sin(x) & \cos(x)
\end{pmatrix}\begin{pmatrix} \cos(x) & -\sin(x)\\ \sin(x) & \cos(x)
\end{pmatrix}=I$$

$$\det(A)=1$$

Yet I'm not sure how to compute it, this is what I tried:

>> A=[cos(x) -sin(x);
sin(x) cos(x)]

A =

[ cos(x), -sin(x)]
[ sin(x),  cos(x)]

>> A'*A

ans =

[ cos(conj(x))*cos(x) + sin(conj(x))*sin(x), sin(conj(x))*cos(x) - cos(conj(x))*sin(x)]
[ cos(conj(x))*sin(x) - sin(conj(x))*cos(x), cos(conj(x))*cos(x) + sin(conj(x))*sin(x)]

Indeed, shouldn't the top left hand corner be $1$?

Here is something weird about the transposed:

>>A'
ans =

[  cos(conj(x)), sin(conj(x))]
[ -sin(conj(x)), cos(conj(x))]

Best Answer

If $x$ is real, then it should be declared as such:

>> x = sym('x','real');
>> A = [cos(x) -sin(x); sin(x) cos(x)]

A =

[  cos(x), -sin(x)]
[  sin(x),  cos(x)]


>> A'

ans =

[  cos(x),  sin(x)]
[ -sin(x),  cos(x)]


>> A'*A

ans =

[ cos(x)^2+sin(x)^2,                 0]
[                 0, cos(x)^2+sin(x)^2]


>> simplify(ans)

ans =

[ 1, 0]
[ 0, 1]