%% Compare Matrix Logarithms
% Calculate the matrix exponential of a matrix, A.

A = [1 1 0; 0 0 2; 0 0 -1];
Y = expm(A)

%
% Calculate the matrix logarithm of Y to reproduce the original matrix, A.

P = logm(Y)

%
% log(A) involves taking the logarithm of zero, so it produces inferior results.

Q = log(A)

% Copyright 2015 The MathWorks, Inc.