You are on page 1of 6

EXPERIMENT- 2

BASIC OPERATION OF MATRIX


AIM: Write commands to perform basic operations of MATLAB tool.

SOFTWARE REQUIRED: PC loaded with SCILAB software THEORY: Vectors are special forms of matrices
and contain only one row or one column. Whereas scalars are special forms of matrices and contain only
one row and one column. A matrix with one row is called row vector and a matrix with single column is
called column vector.

PROCEDURE:
1. Click on SCILAB Icon
2. Click on launch scinotes.
3. Type the program on editor window
4. Save the program with filename.sce extension
5. Execute the program and observe the output.

Program
A= input('Enter the matrix A ::');
B= input('Enter the matrix B ::');

disp('The Size of matrix A is:: ');


disp(size(A));
disp('The Size of matrix B is:: ');
disp(size(B));

disp('Addition of matrix A and B is::');


disp(A+B)

disp('Substraction of matrix A and B is::');


disp(A-B)

disp('Multiplication of matrix A and B is::');


disp(A.*B)

disp('Rank of matrix A is:: ');


disp(rank(A));

disp('Rank of matrix B is:: ');


disp(rank(B));

disp('Determinant of matrix A is:: ');


disp(det(A));
disp('Determinant of matrix B is:: ');
disp(size(B));

disp('Trace of matrix A is:: ');


disp(trace(A));

disp('Trace of matrix B is:: ');


disp(trace(B));

disp('Inverse of matrix A is:: ');


disp(inv(A));

disp('Inverse of matrix B is:: ');


disp(inv(B));

Output-
Enter the matrix A ::[1,4;1,6]

Enter the matrix B ::[1,2;1,3]

"The Size of matrix A is:: "

2. 2.

"The Size of matrix B is:: "

2. 2.

"Addition of matrix A and B is::"

2. 6.

2. 9.

"Substraction of matrix A and B is::"

0. 2.

0. 3.

"Multiplication of matrix A and B is::"


1. 8.

1. 18.

"Rank of matrix A is:: "

2.

"Rank of matrix B is:: "

2.

"Determinant of matrix A is:: "

2.

"Determinant of matrix B is:: "

2. 2.

"Trace of matrix A is:: "

7.

"Trace of matrix B is:: "

4.

"Inverse of matrix A is:: "

3. -2.

-0.5 0.5

"Inverse of matrix B is:: "

3. -2. -1. 1.
SHRI RAMSWAROOP MEMORIAL
UNIVERSITY

IT WORKSHOP LAB
(BCS 4520)

LAB FILE
SESSION: 2021-2022

SUBMITTED TO: SUBMITTED BY:


Er.Dolly Sharma Abhishek Singh Yadav
Roll No. : 202110101110708
Group : CS-45
INDEX
Faculty
S.No Name of Experiment Date Remarks
Signature

10

You might also like