Impact-Site-Verification: dbe48ff9-4514-40fe-8cc0-70131430799e

Search This Blog

Program for Matrix Analysis




1. Determinant
2. Singularity
3. Orthogonality
4. Inverse
5. Transpose
6. Square of matrix
4. Eigne values and eigen vectors
6. Rank of a matrix

Code: 

clc

close all

clear all

 

% A = [1 -2i; 1i -2]; % Given matrix

A = [1 2 3; 0 1 5; 5 6 0]

detA = det(A); % Determinant

fprintf('The determinant is:\n');

disp(detA);

%% Check for singularity with conditional statement

if detA == 0

fprintf('The given matrix is singular\n');

else

fprintf('The given matrix is non singular\n');

end

 

%% Check for orthogonality with conditional statement

if detA == 1 || detA == -1

fprintf('The given matrix is orthogonal\n');

else

fprintf('The given matrix is non orthogonal\n');

end

 

invA = inv(A); % Inverse

fprintf('The inverse is:\n');

disp(invA);

transA = transpose(A); % Transpose

fprintf('The transpose is:\n');

disp(transA);

squareA = A*A; % Square value of matrix

fprintf('The square of given matrix is:\n');

disp(squareA);

%% Eigne values and Eigne vectors

eigVal = eig(A); % Eigen values

fprintf('The eigen values are:\n');

disp(eigVal);

% or

[V D] = eig(A); % Eigen vectors and eigen velues

fprintf('The eigen vector and eigen values are:\n');

disp(V);

disp(D);

%% Rank

rankA = rank(A);

fprintf('The rank is:\n');

disp(rankA);

 


A =


     1     2     3

     0     1     5

     5     6     0


The determinant is:

    5.0000


The given matrix is non singular

The given matrix is non orthogonal

The inverse is:

   -6.0000    3.6000    1.4000

    5.0000   -3.0000   -1.0000

   -1.0000    0.8000    0.2000


The transpose is:

     1     0     5

     2     1     6

     3     5     0


The square of given matrix is:

    16    22    13

    25    31     5

     5    16    45


The eigen values are:

   -5.6418

   -0.1143

    7.7561


The eigen vector and eigen values are:

    0.1769   -0.7592   -0.4704

    0.5919    0.6353   -0.5250

   -0.7863   -0.1416   -0.7093


   -5.6418         0         0

         0   -0.1143         0

         0         0    7.7561


The rank is:

     3


>> 



Join us on Telegram: https://t.me/matlabcastor

No comments

Popular Posts

Followers