zaro

How to find the adjoint of a matrix in MATLAB?

Published in MATLAB Matrix Operations 3 mins read

In MATLAB, you can find the Classical Adjoint (Adjugate) of a matrix directly using the adjoint() function.

Understanding the Adjoint

The adjoint (specifically, the Classical Adjoint or Adjugate matrix) of a square matrix A is the transpose of its cofactor matrix. It has a special property related to the inverse and determinant of the matrix.

According to the reference, the function adjoint( A ) returns the Classical Adjoint (Adjugate) Matrix X of A. This matrix X satisfies the fundamental property:

A * X = det(A) * eye(n) = X * A

where det(A) is the determinant of matrix A, eye(n) is the identity matrix of size n x n, and n is the number of rows (or columns) in A. For an invertible matrix, the inverse can be found using the adjoint: A⁻¹ = (1/det(A)) * adj(A).

Using the adjoint() Function in MATLAB

The simplest way to compute the adjoint in MATLAB is to use the built-in adjoint() function.

Steps to Find the Adjoint

  1. Define your square matrix A.
  2. Call the adjoint() function with A as the argument.

MATLAB Example

Let's find the adjoint of a simple 3x3 matrix using MATLAB.

% Define the matrix A
A = [1, 2, 3;
     0, 1, 4;
     5, 6, 0];

% Calculate the adjoint of A
X = adjoint(A);

% Display the result
disp('Matrix A:');
disp(A);
disp('Adjoint of A (X):');
disp(X);

% Verify the property A * X = det(A) * eye(n)
det_A = det(A);
n = size(A, 1); % Get the number of rows
Identity_Matrix = eye(n);

AX = A * X;
detA_I = det_A * Identity_Matrix;

disp('A * X:');
disp(AX);
disp('det(A) * eye(n):');
disp(detA_I);

% Check if A * X is approximately equal to det(A) * eye(n)
is_verified = isalmost(AX, detA_I); % Use isalmost for floating-point comparison
fprintf('Is A * X approximately equal to det(A) * eye(n)? %s\n', string(is_verified));

When you run this code in MATLAB, the output will show the original matrix A, its calculated adjoint X, and the results of the verification A * X and det(A) * eye(n), demonstrating the property mentioned in the reference.

Output Interpretation

The variable X will store the computed classical adjoint (adjugate) matrix of A.

Table: Key Function and Property

Element Description MATLAB Function/Property
Matrix A The input square matrix. Defined by the user (e.g., A = [...])
Adjoint (Adjugate) The matrix X such that A*X = det(A)*eye(n). adjoint(A)
Determinant A scalar value associated with a square matrix. det(A)
Identity Matrix A square matrix with ones on the main diagonal and zeros elsewhere. eye(n) (where n is the matrix size)
Matrix Multiplication The product of two matrices. A * X
Scalar Multiplication Multiplying a matrix by a scalar. det(A) * eye(n)

By utilizing the adjoint(A) function, finding the adjoint of a matrix in MATLAB is a straightforward task.