MATLAB: How to test if a matrix is unitary

conjugateinversematrixunitary

My current test for a unitary matrix is shown in the code, I'd also like to know if U = e^(iH) [i is the complex number] is coded correctly. Thanks!
U = exp(i*H)
Uinverse = inv(U)
UConjTran = U'
if UConjTran == Uinverse
disp('U is unitary')
else
disp('U is NOT unitary')
end

Best Answer

Again, e^(i*H) is not the same as exp(i*H). Check matlab's "mpower" operator.
Related Question