You are on page 1of 4

% Basic arithmetic operation on Matrixs

clc;
clear all;
B= [1 2 3;4 5 6;7 8 9];
A= [6 5 2;4 4 5;2 1 3];
disp('A=');
disp(A);
disp('B=');
disp(B);
%MATRIX ADDITION
C= A+B;
disp('The addition of Two input A and B is=');
disp(C);
%MATRIX SUBTRACTION
D= A-B;
disp('The subtraction of Two input A and B is=');
disp(D);
%MATRIX MULTIPLICATION
E= A*B;
disp('The Multiplication of Two input A and B is=');
disp(E);
%MATRIX DIVISION
F= A/B;
disp('The Division of A by B is=');
disp(F);
% MATRIX DIVISION
G= A*inv(B);
disp('The Division of A by B is=');
disp(G);
%MATRIX INVERSION
H=inv(A);
disp('Inverse of Matrix A=');
disp(H);
% DETERMINANT OF A MATRIX
I=det(A);
disp('Determinant of matrix A=');
disp(I);

% Concatination of Two Matrices


J=[A B];
disp('Horizontal Concatenation of matrix A and B is');
disp(J);
K=[A;B];
disp('Vertical Concatenation of matrix A and B is');
disp(K);
OUTPUT:

A=

6 5 2

4 4 5

2 1 3

B=

1 2 3

4 5 6

7 8 9

The addition of Two input A and B is=

7 7 5

8 9 11

9 9 12

The subtraction of Two input A and B is=

5 3 -1

0 -1 -1

-5 -7 -6

The Multiplication of Two input A and B is=

40 53 66

55 68 81

27 33 39

Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =

1.156482e-18.

> In basicmatrixoprn at 23

The Division of A by B is= 1.0e+16 *


0.9007 -1.8014 0.9007

-0.4504 0.9007 -0.4504

-1.3511 2.7022 -1.3511

Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =

1.541976e-18.

> In basicmatrixoprn at 27

The Division of A by B is=

1.0e+16 *

0.9007 -1.8014 0.9007

-0.4504 0.9007 -0.4504

-1.3511 2.7022 -1.3511

Inverse of Matrix A=

0.2917 -0.5417 0.7083

-0.0833 0.5833 -0.9167

-0.1667 0.1667 0.1667

Determinant of matrix A=

24.0000

Horizontal Concatenation of matrix A and B is

6 5 2 1 2 3

4 4 5 4 5 6

2 1 3 7 8 9
Vertical Concatenation of matrix A and B is

6 5 2

4 4 5

2 1 3

1 2 3

4 5 6

7 8 9

You might also like